Commit 9e0e43e4 authored by Wayne Stambaugh's avatar Wayne Stambaugh

EESchema and other minor code improvements.

* Change EDA_ITEM set flag function to set flag bits using logical or
  instead of assignment.
* Add clear flag function to EDA_ITEM to clear flag bit using inverted
  logical and.
* Factor change schematic text type code out of switch statement into
  a single function call.
* Schematic text orientation function renaming improvements.
* Lots of small coding policy changes to updated files.
parent bd99012a
......@@ -128,7 +128,7 @@ void DialogLabelEditor::InitDialog()
EnsureTextCtrlWidth( m_textLabel, &textWidth );
// Set validators
m_TextOrient->SetSelection( m_CurrentText->GetSchematicTextOrientation() );
m_TextOrient->SetSelection( m_CurrentText->GetOrientation() );
m_TextShape->SetSelection( m_CurrentText->m_Shape );
int style = 0;
......@@ -205,7 +205,7 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& aEvent )
else if( (m_CurrentText->m_Flags & IS_NEW) == 0 )
DisplayError( this, _( "Empty Text!" ) );
m_CurrentText->SetSchematicTextOrientation( m_TextOrient->GetSelection() );
m_CurrentText->SetOrientation( m_TextOrient->GetSelection() );
text = m_TextSize->GetValue();
value = ReturnValueFromString( g_UserUnit, text, m_Parent->m_InternalUnits );
m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value;
......
/*********************************************************************/
/* EESchema */
/* edit_label.cpp: label, global label and text creation or edition */
/*********************************************************************/
......@@ -12,10 +11,12 @@
#include "confirm.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "kicad_device_context.h"
#include "general.h"
#include "protos.h"
#include "sch_text.h"
#include "eeschema_id.h"
static void ShowWhileMoving( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
......@@ -32,114 +33,112 @@ static bool lastTextBold = false;
static bool lastTextItalic = false;
void SCH_EDIT_FRAME::StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC )
void SCH_EDIT_FRAME::StartMoveTexte( SCH_TEXT* aTextItem, wxDC* aDC )
{
if( TextStruct == NULL )
if( aTextItem == NULL )
return;
m_itemToRepeat = NULL;
if( !TextStruct->IsNew() )
if( !aTextItem->IsNew() )
{
delete g_ItemToUndoCopy;
g_ItemToUndoCopy = TextStruct->Clone();
g_ItemToUndoCopy = aTextItem->Clone();
}
TextStruct->m_Flags |= IS_MOVED;
aTextItem->SetFlags( IS_MOVED );
switch( TextStruct->Type() )
switch( aTextItem->Type() )
{
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_TEXT_T:
ItemInitialPosition = TextStruct->m_Pos;
OldSize = TextStruct->m_Size;
OldOrient = TextStruct->GetSchematicTextOrientation();
ItemInitialPosition = aTextItem->m_Pos;
OldSize = aTextItem->m_Size;
OldOrient = aTextItem->GetOrientation();
break;
default:
break;
}
DrawPanel->CrossHairOff( DC );
DrawPanel->CrossHairOff( aDC );
GetScreen()->SetCrossHairPosition( ItemInitialPosition );
DrawPanel->MoveCursorToCrossHair();
OnModify( );
DrawPanel->SetMouseCapture( ShowWhileMoving,ExitMoveTexte );
GetScreen()->SetCurItem( TextStruct );
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, true );
OnModify();
DrawPanel->SetMouseCapture( ShowWhileMoving, ExitMoveTexte );
GetScreen()->SetCurItem( aTextItem );
DrawPanel->m_mouseCaptureCallback( DrawPanel, aDC, wxDefaultPosition, true );
DrawPanel->CrossHairOn( DC );
DrawPanel->CrossHairOn( aDC );
}
void SCH_EDIT_FRAME::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC )
void SCH_EDIT_FRAME::ChangeTextOrient( SCH_TEXT* aTextItem, wxDC* aDC )
{
if( TextStruct == NULL )
TextStruct = (SCH_TEXT*) PickStruct( GetScreen()->GetCrossHairPosition(),
if( aTextItem == NULL )
aTextItem = (SCH_TEXT*) PickStruct( GetScreen()->GetCrossHairPosition(),
GetScreen(), TEXT_T | LABEL_T );
if( TextStruct == NULL )
if( aTextItem == NULL )
return;
/* save old text in undo list if is not already in edit */
if( TextStruct->m_Flags == 0 )
SaveCopyInUndoList( TextStruct, UR_CHANGED );
if( aTextItem->GetFlags() == 0 )
SaveCopyInUndoList( aTextItem, UR_CHANGED );
/* Erase old text */
DrawPanel->CrossHairOff( DC );
TextStruct->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
DrawPanel->CrossHairOff( aDC );
aTextItem->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
int orient;
switch( TextStruct->Type() )
switch( aTextItem->Type() )
{
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_TEXT_T:
orient = TextStruct->GetSchematicTextOrientation() + 1;
orient = aTextItem->GetOrientation() + 1;
orient &= 3;
TextStruct->SetSchematicTextOrientation( orient );
aTextItem->SetOrientation( orient );
break;
default:
break;
}
OnModify( );
TextStruct->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
DrawPanel->CrossHairOn( DC );
OnModify();
aTextItem->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
DrawPanel->CrossHairOn( aDC );
}
/* Routine to create new text struct (GraphicText, label or Glabel).
*/
SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* DC, int type )
SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType )
{
SCH_TEXT* NewText = NULL;
SCH_TEXT* textItem = NULL;
m_itemToRepeat = NULL;
switch( type )
switch( aType )
{
case LAYER_NOTES:
NewText = new SCH_TEXT( GetScreen()->GetCrossHairPosition() );
textItem = new SCH_TEXT( GetScreen()->GetCrossHairPosition() );
break;
case LAYER_LOCLABEL:
NewText = new SCH_LABEL( GetScreen()->GetCrossHairPosition() );
textItem = new SCH_LABEL( GetScreen()->GetCrossHairPosition() );
break;
case LAYER_HIERLABEL:
NewText = new SCH_HIERLABEL( GetScreen()->GetCrossHairPosition() );
NewText->m_Shape = lastGlobalLabelShape;
textItem = new SCH_HIERLABEL( GetScreen()->GetCrossHairPosition() );
textItem->m_Shape = lastGlobalLabelShape;
break;
case LAYER_GLOBLABEL:
NewText = new SCH_GLOBALLABEL( GetScreen()->GetCrossHairPosition() );
NewText->m_Shape = lastGlobalLabelShape;
textItem = new SCH_GLOBALLABEL( GetScreen()->GetCrossHairPosition() );
textItem->m_Shape = lastGlobalLabelShape;
break;
default:
......@@ -147,104 +146,99 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* DC, int type )
return NULL;
}
NewText->m_Bold = lastTextBold;
NewText->m_Italic = lastTextItalic;
NewText->SetSchematicTextOrientation( lastTextOrientation );
NewText->m_Size.x = NewText->m_Size.y = g_DefaultTextLabelSize;
NewText->m_Flags = IS_NEW | IS_MOVED;
textItem->m_Bold = lastTextBold;
textItem->m_Italic = lastTextItalic;
textItem->SetOrientation( lastTextOrientation );
textItem->m_Size.x = textItem->m_Size.y = g_DefaultTextLabelSize;
textItem->SetFlags( IS_NEW | IS_MOVED );
NewText->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
EditSchematicText( NewText );
textItem->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
EditSchematicText( textItem );
if( NewText->m_Text.IsEmpty() )
if( textItem->m_Text.IsEmpty() )
{
SAFE_DELETE( NewText );
SAFE_DELETE( textItem );
return NULL;
}
lastTextBold = NewText->m_Bold;
lastTextItalic = NewText->m_Italic;
lastTextOrientation = NewText->GetSchematicTextOrientation();
lastTextBold = textItem->m_Bold;
lastTextItalic = textItem->m_Italic;
lastTextOrientation = textItem->GetOrientation();
if( type == LAYER_GLOBLABEL || type == LAYER_HIERLABEL )
if( aType == LAYER_GLOBLABEL || aType == LAYER_HIERLABEL )
{
lastGlobalLabelShape = NewText->m_Shape;
lastGlobalLabelShape = textItem->m_Shape;
}
NewText->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
textItem->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
DrawPanel->SetMouseCapture( ShowWhileMoving, ExitMoveTexte );
GetScreen()->SetCurItem( NewText );
GetScreen()->SetCurItem( textItem );
return NewText;
return textItem;
}
/************************************/
/* Redraw a Text while moving */
/************************************/
static void ShowWhileMoving( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase )
{
SCH_ITEM* TextStruct = (SCH_ITEM*) aPanel->GetScreen()->GetCurItem();
SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
SCH_ITEM* textItem = screen->GetCurItem();
/* "Undraw" the current text at its old position*/
// Erase the current text at its current position.
if( aErase )
TextStruct->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
textItem->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
/* redraw the text */
switch( TextStruct->Type() )
// Draw the text item at it's new position.
switch( textItem->Type() )
{
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_TEXT_T:
( (SCH_TEXT*) TextStruct )->m_Pos = aPanel->GetScreen()->GetCrossHairPosition();
( (SCH_TEXT*) textItem )->m_Pos = screen->GetCrossHairPosition();
break;
default:
break;
}
TextStruct->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
textItem->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
}
/* Abort function for the command move text */
static void ExitMoveTexte( EDA_DRAW_PANEL* Panel, wxDC* DC )
static void ExitMoveTexte( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
{
BASE_SCREEN* screen = Panel->GetScreen();
SCH_ITEM* Struct = (SCH_ITEM*) screen->GetCurItem();
SCH_EDIT_FRAME* parent = ( SCH_EDIT_FRAME* ) Panel->GetParent();
SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
SCH_ITEM* item = screen->GetCurItem();
SCH_EDIT_FRAME* parent = ( SCH_EDIT_FRAME* ) aPanel->GetParent();
parent->SetRepeatItem( NULL );
if( Struct == NULL ) /* no current item */
{
if( item == NULL ) /* no current item */
return;
}
/* "Undraw" the text, and delete it if new (i.e. it was being just
* created)*/
Struct->Draw( Panel, DC, wxPoint( 0, 0 ), g_XorMode );
// Erase the text item and delete it if new (i.e. it was being just created).
item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
if( Struct->IsNew() )
if( item->IsNew() )
{
SAFE_DELETE( Struct );
SAFE_DELETE( item );
screen->SetCurItem( NULL );
}
else /* this was a move command on "old" text: restore its old settings. */
else // this was a move command on "old" text: restore its old settings.
{
switch( Struct->Type() )
switch( item->Type() )
{
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_TEXT_T:
{
SCH_TEXT* Text = (SCH_TEXT*) Struct;
Text->m_Pos = ItemInitialPosition;
Text->m_Size = OldSize;
Text->SetSchematicTextOrientation( OldOrient );
SCH_TEXT* text = (SCH_TEXT*) item;
text->m_Pos = ItemInitialPosition;
text->m_Size = OldSize;
text->SetOrientation( OldOrient );
}
break;
......@@ -252,62 +246,88 @@ static void ExitMoveTexte( EDA_DRAW_PANEL* Panel, wxDC* DC )
break;
}
Struct->Draw( Panel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
Struct->m_Flags = 0;
item->Draw( aPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
item->ClearFlags();
}
}
/* Routine to change a text type to an other one (GraphicText, label or Glabel).
* A new test, label or hierarchical or global label is created from the old text.
* the old text is deleted
*/
void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* Text, wxDC* DC, int newtype )
void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent )
{
if( Text == NULL )
SCH_SCREEN* screen = GetScreen();
SCH_TEXT* text = (SCH_TEXT*) screen->GetCurItem();
wxCHECK_RET( (text != NULL) && text->CanIncrementLabel(),
wxT( "Cannot convert text type." ) );
KICAD_T type;
switch( aEvent.GetId() )
{
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL:
type = SCH_LABEL_T;
break;
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL:
type = SCH_GLOBAL_LABEL_T;
break;
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL:
type = SCH_HIERARCHICAL_LABEL_T;
break;
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT:
type = SCH_TEXT_T;
break;
default:
wxFAIL_MSG( wxString::Format( wxT( "Invalid text type command ID %d." ),
aEvent.GetId() ) );
return;
}
if( text->Type() == type )
return;
SCH_TEXT* newtext;
switch( newtype )
switch( type )
{
case SCH_LABEL_T:
newtext = new SCH_LABEL( Text->m_Pos, Text->m_Text );
newtext = new SCH_LABEL( text->m_Pos, text->m_Text );
break;
case SCH_GLOBAL_LABEL_T:
newtext = new SCH_GLOBALLABEL( Text->m_Pos, Text->m_Text );
newtext = new SCH_GLOBALLABEL( text->m_Pos, text->m_Text );
break;
case SCH_HIERARCHICAL_LABEL_T:
newtext = new SCH_HIERLABEL( Text->m_Pos, Text->m_Text );
newtext = new SCH_HIERLABEL( text->m_Pos, text->m_Text );
break;
case SCH_TEXT_T:
newtext = new SCH_TEXT( Text->m_Pos, Text->m_Text );
newtext = new SCH_TEXT( text->m_Pos, text->m_Text );
break;
default:
newtext = NULL;
DisplayError( this, wxT( "ConvertTextType: Internal error" ) );
wxFAIL_MSG( wxString::Format( wxT( "Cannot convert text type to %d" ), type ) );
return;
}
/* copy the old text settings
* Justifications are not copied because they are not used in labels,
* and can be used in texts
* So they will be set to default in conversion.
/* Copy the old text item settings to the new one. Justifications are not copied because
* they are not used in labels. Justifications will be set to default value in the new
* text item type.
*/
newtext->m_Shape = Text->m_Shape;
newtext->SetSchematicTextOrientation( Text->GetSchematicTextOrientation() );
newtext->m_Size = Text->m_Size;
newtext->m_Thickness = Text->m_Thickness;
newtext->m_Italic = Text->m_Italic;
newtext->m_Bold = Text->m_Bold;
newtext->m_Shape = text->m_Shape;
newtext->SetOrientation( text->GetOrientation() );
newtext->m_Size = text->m_Size;
newtext->m_Thickness = text->m_Thickness;
newtext->m_Italic = text->m_Italic;
newtext->m_Bold = text->m_Bold;
// save current text flag:
int flags = Text->m_Flags;
int flags = text->GetFlags();
/* add the new text in linked list if old text is in list */
if( (flags & IS_NEW) == 0 )
......@@ -317,21 +337,18 @@ void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* Text, wxDC* DC, int newtype )
OnModify();
}
/* now delete the old text
* If it is a text flagged IS_NEW it will be deleted by m_endMouseCaptureCallback()
* If not, we must delete it.
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
/* Delete the old text item. If it is a text flagged as new it will be deleted by
* ending the mouse capture.
*/
if( DrawPanel->m_mouseCaptureCallback && DrawPanel->m_endMouseCaptureCallback )
{
DrawPanel->m_endMouseCaptureCallback( DrawPanel, DC );
}
if( DrawPanel->IsMouseCaptured() )
DrawPanel->EndMouseCapture();
if( (flags & IS_NEW) == 0 ) // Remove old text from current list and
// save it in undo list
if( (flags & IS_NEW) == 0 ) // Remove old text from current list and save it in undo list
{
Text->m_Flags = 0;
DeleteStruct( DrawPanel, DC, Text ); // old text is really saved in
// undo list
text->ClearFlags();
DeleteStruct( DrawPanel, &dc, text ); // old text is really saved in undo list
GetScreen()->SetCurItem( NULL );
m_itemToRepeat = NULL;
}
......@@ -341,7 +358,7 @@ void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* Text, wxDC* DC, int newtype )
delete g_ItemToUndoCopy;
g_ItemToUndoCopy = NULL;
DrawPanel->CrossHairOff( DC ); // Erase schematic cursor
DrawPanel->CrossHairOff( &dc ); // Erase schematic cursor
/* Save the new text in undo list if the old text was not itself a "new created text"
* In this case, the old text is already in undo list as a deleted item.
......@@ -355,16 +372,15 @@ void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* Text, wxDC* DC, int newtype )
else
{
GetScreen()->SetCurItem( newtext );
newtext->m_Flags = IS_NEW;
newtext->SetFlags( IS_NEW );
}
if( (flags & IS_MOVED) != 0 )
{
GetScreen()->SetCurItem( newtext );
StartMoveTexte( newtext, DC );
StartMoveTexte( newtext, &dc );
}
newtext->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
DrawPanel->CrossHairOn( DC ); // redraw schematic cursor
newtext->Draw( DrawPanel, &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
DrawPanel->CrossHairOn( &dc ); // redraw schematic cursor
}
......@@ -87,17 +87,12 @@ enum id_eeschema_frm
ID_POPUP_SCH_EDIT_CONVERT_CMP,
ID_POPUP_SCH_ROTATE_FIELD,
ID_POPUP_SCH_EDIT_FIELD,
ID_POPUP_SCH_CHANGE_TYPE_TEXT,
ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL,
ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL,
ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT,
ID_POPUP_SCH_DISPLAYDOC_CMP,
ID_POPUP_SCH_ENTER_SHEET,
ID_POPUP_SCH_LEAVE_SHEET,
ID_POPUP_SCH_ADD_JUNCTION,
ID_POPUP_SCH_ADD_LABEL,
ID_POPUP_SCH_ADD_GLABEL,
ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL,
ID_POPUP_SCH_GETINFO_MARKER,
ID_POPUP_END_RANGE,
......@@ -130,6 +125,13 @@ enum id_eeschema_frm
ID_POPUP_SCH_SELECT_UNIT25,
ID_POPUP_SCH_SELECT_UNIT26,
// Change text type context menu command IDs.
ID_POPUP_SCH_CHANGE_TYPE_TEXT,
ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL,
ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL,
ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL,
ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT,
// Schematic editor commmands. These are command IDs that are generated by multiple
// events (menus, toolbar, context menu, etc.) that result in the same event handler.
ID_CANCEL_CURRENT_COMMAND,
......
......@@ -709,7 +709,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->MoveCursorToCrossHair();
int oldFlags = m_drawItem->GetFlags();
m_drawItem->SetFlags( 0 );
m_drawItem->ClearFlags();
m_drawItem->Draw( DrawPanel, &dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL, DefaultTransform );
( (LIB_POLYLINE*) m_drawItem )->DeleteSegment( GetScreen()->GetCrossHairPosition( true ) );
m_drawItem->Draw( DrawPanel, &dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL, DefaultTransform );
......
......@@ -62,7 +62,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
default:
wxFAIL_MSG( wxT( "SCH_EDIT_FRAME::OnLeftClick error. Item type <" ) +
item->GetClass() + wxT( "> is already being edited." ) );
item->SetFlags( 0 );
item->ClearFlags();
}
}
else
......
......@@ -123,22 +123,22 @@ void SCH_SHEET_PIN::SetEdge( int aEdge )
{
case 0: /* pin on left side*/
m_Pos.x = Sheet->m_Pos.x;
SetSchematicTextOrientation( 2 ); /* Orientation horiz inverse */
SetOrientation( 2 ); /* Orientation horiz inverse */
break;
case 1: /* pin on right side*/
m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x;
SetSchematicTextOrientation( 0 ); /* Orientation horiz normal */
SetOrientation( 0 ); /* Orientation horiz normal */
break;
case 2: /* pin on top side*/
m_Pos.y = Sheet->m_Pos.y;
SetSchematicTextOrientation( 3 ); /* Orientation vert BOTTOM */
SetOrientation( 3 ); /* Orientation vert BOTTOM */
break;
case 3: /* pin on bottom side*/
m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y;
SetSchematicTextOrientation( 1 ); /* Orientation vert UP */
SetOrientation( 1 ); /* Orientation vert UP */
break;
}
}
......
......@@ -165,7 +165,7 @@ void SCH_TEXT::Mirror_Y( int aYaxis_position )
int px = m_Pos.x;
int dx;
switch( GetSchematicTextOrientation() )
switch( GetOrientation() )
{
case 0: /* horizontal text */
dx = LenSize( m_Text ) / 2;
......@@ -206,7 +206,7 @@ void SCH_TEXT::Mirror_X( int aXaxis_position )
int py = m_Pos.y;
int dy;
switch( GetSchematicTextOrientation() )
switch( GetOrientation() )
{
case 0: /* horizontal text */
dy = -m_Size.y / 2;
......@@ -243,8 +243,9 @@ void SCH_TEXT::Rotate( wxPoint rotationPoint )
int dy;
RotatePoint( &m_Pos, rotationPoint, 900 );
SetSchematicTextOrientation( (GetSchematicTextOrientation() + 1) % 4 );
switch( GetSchematicTextOrientation() )
SetOrientation( (GetOrientation() + 1) % 4 );
switch( GetOrientation() )
{
case 0: /* horizontal text */
dy = m_Size.y;
......@@ -271,9 +272,9 @@ void SCH_TEXT::Rotate( wxPoint rotationPoint )
}
void SCH_TEXT::SetSchematicTextOrientation( int aSchematicOrientation )
void SCH_TEXT::SetOrientation( int aOrientation )
{
m_SchematicOrientation = aSchematicOrientation;
m_SchematicOrientation = aOrientation;
switch( m_SchematicOrientation )
{
......@@ -491,7 +492,7 @@ bool SCH_TEXT::Load( LINE_READER& aLine, wxString& aErrorMsg )
m_Text = val;
m_Size.x = m_Size.y = size;
SetSchematicTextOrientation( orient );
SetOrientation( orient );
if( isdigit( Name3[0] ) )
{
......@@ -681,9 +682,9 @@ wxPoint SCH_LABEL::GetSchematicTextOffset()
}
void SCH_LABEL::SetSchematicTextOrientation( int aSchematicOrientation )
void SCH_LABEL::SetOrientation( int aOrientation )
{
SCH_TEXT::SetSchematicTextOrientation( aSchematicOrientation );
SCH_TEXT::SetOrientation( aOrientation );
}
......@@ -705,7 +706,7 @@ void SCH_LABEL::Mirror_X( int aXaxis_position )
void SCH_LABEL::Rotate( wxPoint rotationPoint )
{
RotatePoint( &m_Pos, rotationPoint, 900 );
SetSchematicTextOrientation( (GetSchematicTextOrientation() + 1) % 4 );
SetOrientation( (GetOrientation() + 1) % 4 );
}
......@@ -774,7 +775,7 @@ bool SCH_LABEL::Load( LINE_READER& aLine, wxString& aErrorMsg )
m_Text = FROM_UTF8( text );
m_Size.x = m_Size.y = size;
SetSchematicTextOrientation( orient );
SetOrientation( orient );
if( isdigit( Name3[0] ) )
{
......@@ -940,7 +941,7 @@ bool SCH_GLOBALLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg )
m_Text = FROM_UTF8( text );
m_Size.x = m_Size.y = size;
SetSchematicTextOrientation( orient );
SetOrientation( orient );
m_Shape = NET_INPUT;
m_Bold = ( thickness != 0 );
m_Thickness = m_Bold ? GetPenSizeForBold( size ) : 0;
......@@ -971,14 +972,14 @@ void SCH_GLOBALLABEL::Mirror_Y( int aYaxis_position )
* for a vertical label, the schematic orientation is not changed.
* and the label is moved to a suitable position
*/
switch( GetSchematicTextOrientation() )
switch( GetOrientation() )
{
case 0: /* horizontal text */
SetSchematicTextOrientation( 2 );
SetOrientation( 2 );
break;
case 2: /* invert horizontal text*/
SetSchematicTextOrientation( 0 );
SetOrientation( 0 );
break;
}
......@@ -990,14 +991,14 @@ void SCH_GLOBALLABEL::Mirror_Y( int aYaxis_position )
void SCH_GLOBALLABEL::Mirror_X( int aXaxis_position )
{
switch( GetSchematicTextOrientation() )
switch( GetOrientation() )
{
case 1: /* vertical text */
SetSchematicTextOrientation( 3 );
SetOrientation( 3 );
break;
case 3: /* invert vertical text*/
SetSchematicTextOrientation( 1 );
SetOrientation( 1 );
break;
}
......@@ -1010,7 +1011,7 @@ void SCH_GLOBALLABEL::Mirror_X( int aXaxis_position )
void SCH_GLOBALLABEL::Rotate( wxPoint rotationPoint )
{
RotatePoint( &m_Pos, rotationPoint, 900 );
SetSchematicTextOrientation( (GetSchematicTextOrientation() + 3) % 4 );
SetOrientation( (GetOrientation() + 3) % 4 );
}
......@@ -1063,9 +1064,9 @@ wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset()
}
void SCH_GLOBALLABEL::SetSchematicTextOrientation( int aSchematicOrientation )
void SCH_GLOBALLABEL::SetOrientation( int aOrientation )
{
m_SchematicOrientation = aSchematicOrientation;
m_SchematicOrientation = aOrientation;
switch( m_SchematicOrientation )
{
......@@ -1366,7 +1367,7 @@ bool SCH_HIERLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg )
m_Text = FROM_UTF8( text );
m_Size.x = m_Size.y = size;
SetSchematicTextOrientation( orient );
SetOrientation( orient );
m_Shape = NET_INPUT;
m_Bold = ( thickness != 0 );
m_Thickness = m_Bold ? GetPenSizeForBold( size ) : 0;
......@@ -1390,9 +1391,9 @@ bool SCH_HIERLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg )
}
void SCH_HIERLABEL::SetSchematicTextOrientation( int aSchematicOrientation )
void SCH_HIERLABEL::SetOrientation( int aOrientation )
{
m_SchematicOrientation = aSchematicOrientation;
m_SchematicOrientation = aOrientation;
switch( m_SchematicOrientation )
{
......@@ -1578,14 +1579,14 @@ void SCH_HIERLABEL::Mirror_Y( int aYaxis_position )
* and the label is moved to a suitable position.
*/
switch( GetSchematicTextOrientation() )
switch( GetOrientation() )
{
case 0: /* horizontal text */
SetSchematicTextOrientation( 2 );
SetOrientation( 2 );
break;
case 2: /* invert horizontal text*/
SetSchematicTextOrientation( 0 );
SetOrientation( 0 );
break;
}
......@@ -1597,14 +1598,14 @@ void SCH_HIERLABEL::Mirror_Y( int aYaxis_position )
void SCH_HIERLABEL::Mirror_X( int aXaxis_position )
{
switch( GetSchematicTextOrientation() )
switch( GetOrientation() )
{
case 1: /* vertical text */
SetSchematicTextOrientation( 3 );
SetOrientation( 3 );
break;
case 3: /* invert vertical text*/
SetSchematicTextOrientation( 1 );
SetOrientation( 1 );
break;
}
......@@ -1617,7 +1618,7 @@ void SCH_HIERLABEL::Mirror_X( int aXaxis_position )
void SCH_HIERLABEL::Rotate( wxPoint rotationPoint )
{
RotatePoint( &m_Pos, rotationPoint, 900 );
SetSchematicTextOrientation( (GetSchematicTextOrientation() + 3) % 4 );
SetOrientation( (GetOrientation() + 3) % 4 );
}
......
......@@ -73,7 +73,7 @@ public:
void IncrementLabel();
/**
* Function SetTextOrientAndJustifyParmeters
* Function SetOrientation
* Set m_SchematicOrientation, and initialize
* m_orient,m_HJustified and m_VJustified, according to the value of
* m_SchematicOrientation (for a text )
......@@ -85,9 +85,9 @@ public:
* position of 0
* 3 = bottom . This can be seen as the mirrored position of up
*/
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
virtual void SetOrientation( int aSchematicOrientation );
int GetSchematicTextOrientation() { return m_SchematicOrientation; }
int GetOrientation() { return m_SchematicOrientation; }
/**
* Function GetSchematicTextOffset (virtual)
......@@ -234,7 +234,7 @@ public:
}
/**
* Function SetTextOrientAndJustifyParmeters
* Function SetOrientation
* Set m_SchematicOrientation, and initialize
* m_orient,m_HJustified and m_VJustified, according to the value of
* m_SchematicOrientation (for a label)
......@@ -246,7 +246,7 @@ public:
* position of 0
* 3 = bottom . This can be seen as the mirrored position of up
*/
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
virtual void SetOrientation( int aSchematicOrientation );
/**
* Function GetSchematicTextOffset (virtual)
......@@ -319,7 +319,7 @@ public:
}
/**
* Function SetTextOrientAndJustifyParmeters
* Function SetOrientation
* Set m_SchematicOrientation, and initialize
* m_orient,m_HJustified and m_VJustified, according to the value of
* m_SchematicOrientation
......@@ -331,7 +331,7 @@ public:
* position of 0
* 3 = bottom . This can be seen as the mirrored position of up
*/
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
virtual void SetOrientation( int aSchematicOrientation );
/**
* Function GetSchematicTextOffset (virtual)
......@@ -420,7 +420,7 @@ public:
}
/**
* Function SetTextOrientAndJustifyParmeters
* Function SetOrientation
* Set m_SchematicOrientation, and initialize
* m_orient,m_HJustified and m_VJustified, according to the value of
* m_SchematicOrientation
......@@ -432,7 +432,7 @@ public:
* position of 0
* 3 = bottom . This can be seen as the mirrored position of up
*/
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
virtual void SetOrientation( int aSchematicOrientation );
/**
* Function GetSchematicTextOffset (virtual)
......
......@@ -42,10 +42,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH:
case ID_POPUP_END_LINE:
case ID_POPUP_SCH_EDIT_TEXT:
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL:
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL:
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT:
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL:
case ID_POPUP_SCH_SET_SHAPE_TEXT:
case ID_POPUP_SCH_ROTATE_TEXT:
case ID_POPUP_SCH_EDIT_SHEET:
......@@ -160,26 +156,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
ChangeTextOrient( (SCH_TEXT*) screen->GetCurItem(), &dc );
break;
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL:
DrawPanel->MoveCursorToCrossHair();
ConvertTextType( (SCH_TEXT*) screen->GetCurItem(), &dc, SCH_LABEL_T );
break;
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL:
DrawPanel->MoveCursorToCrossHair();
ConvertTextType( (SCH_TEXT*) screen->GetCurItem(), &dc, SCH_GLOBAL_LABEL_T );
break;
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL:
DrawPanel->MoveCursorToCrossHair();
ConvertTextType( (SCH_TEXT*) screen->GetCurItem(), &dc, SCH_HIERARCHICAL_LABEL_T );
break;
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT:
DrawPanel->MoveCursorToCrossHair();
ConvertTextType( (SCH_TEXT*) screen->GetCurItem(), &dc, SCH_TEXT_T );
break;
case ID_POPUP_SCH_SET_SHAPE_TEXT:
// Not used
......@@ -197,7 +173,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_DELETE_NODE:
case ID_POPUP_SCH_DELETE_CONNECTION:
DrawPanel->MoveCursorToCrossHair();
DeleteConnection( id == ID_POPUP_SCH_DELETE_CONNECTION ? TRUE : FALSE );
DeleteConnection( id == ID_POPUP_SCH_DELETE_CONNECTION ? true : false );
screen->SetCurItem( NULL );
m_itemToRepeat = NULL;
screen->TestDanglingEnds( DrawPanel, &dc );
......@@ -514,7 +490,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_PLACE_BLOCK:
DrawPanel->m_AutoPAN_Request = FALSE;
DrawPanel->m_AutoPAN_Request = false;
DrawPanel->MoveCursorToCrossHair();
HandleBlockPlace( &dc );
break;
......
......@@ -118,9 +118,10 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
SCH_EDIT_FRAME::Process_Special_Functions )
EVT_MENU_RANGE( ID_POPUP_SCH_SELECT_UNIT1, ID_POPUP_SCH_SELECT_UNIT26,
SCH_EDIT_FRAME::OnSelectUnit )
EVT_MENU_RANGE( ID_POPUP_SCH_CHANGE_TYPE_TEXT, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT,
SCH_EDIT_FRAME::OnConvertTextType )
/* Handle user interface update events. */
EVT_UPDATE_UI( wxID_CUT, SCH_EDIT_FRAME::OnUpdateBlockSelected )
......
......@@ -319,6 +319,8 @@ class DHEAD;
#define END_ONPAD (1 << 23) ///< Pcbnew: flag set for track segment ending on a pad
#define BUSY (1 << 24) ///< Pcbnew: flag indicating that the structure has
// already been edited, in some functions
#define EDA_ITEM_ALL_FLAGS -1
class EDA_ITEM
{
......@@ -425,9 +427,9 @@ public:
m_Status = new_status;
}
void SetFlags( int aFlags ) { m_Flags = aFlags; }
int GetFlags() { return m_Flags; }
void SetFlags( int aMask ) { m_Flags |= aMask; }
void ClearFlags( int aMask = EDA_ITEM_ALL_FLAGS ) { m_Flags &= ~aMask; }
int GetFlags() const { return m_Flags; }
/**
* Function DisplayInfo
......
......@@ -459,11 +459,18 @@ private:
SCH_JUNCTION* AddJunction( wxDC* aDC, const wxPoint& aPosition, bool aPutInUndoList = FALSE );
// Text ,label, glabel
SCH_TEXT* CreateNewText( wxDC* DC, int type );
SCH_TEXT* CreateNewText( wxDC* aDC, int aType );
void EditSchematicText( SCH_TEXT* TextStruct );
void ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC );
void StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC );
void ConvertTextType( SCH_TEXT* Text, wxDC* DC, int newtype );
void ChangeTextOrient( SCH_TEXT* aTextItem, wxDC* aDC );
void StartMoveTexte( SCH_TEXT* aTextItem, wxDC* aDC );
/**
* Function OnCovertTextType
* is a command event handler to change a text type to an other one. The new text,
* label, hierarchical label, or global label is created from the old text and the
* old text is deleted.
*/
void OnConvertTextType( wxCommandEvent& aEvent );
// Wire, Bus
void BeginSegment( wxDC* DC, int type );
......
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