Commit c7ec524f authored by lifekidyeaa's avatar lifekidyeaa
Browse files

eeschema: fixed:

* crash when creating a sheet that does not yet have a sch file
* when loading schematic file v 1 annotations are applied to all sheets independent of path in hierarchy
* component reference is drawn by default upon placing a new libary comp. 
parent 87f4916a
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -62,6 +62,7 @@ static inline int USCALE( us arg, us num, us den )


static int inline ZoomValue( int value_to_zoom ) {
static int inline ZoomValue( int value_to_zoom ) {
    int zoom = GET_ZOOM;
    int zoom = GET_ZOOM;
	if( !zoom ) return 0; 


    if( value_to_zoom >= 0 )
    if( value_to_zoom >= 0 )
        return ( value_to_zoom + (zoom >> 1 ) ) / zoom;
        return ( value_to_zoom + (zoom >> 1 ) ) / zoom;
+1 −1
Original line number Original line Diff line number Diff line
@@ -353,9 +353,9 @@ bool DrawSheetStruct::Load(WinEDA_SchematicFrame* frame)
			//do not need to load the sub-sheets - this has already been done.
			//do not need to load the sub-sheets - this has already been done.
		}else{
		}else{
			m_s = new SCH_SCREEN(SCHEMATIC_FRAME); 
			m_s = new SCH_SCREEN(SCHEMATIC_FRAME); 
			m_s->m_RefCount++; 
			if(!frame->LoadOneEEFile(m_s, m_FileName))
			if(!frame->LoadOneEEFile(m_s, m_FileName))
				return false;
				return false;
			m_s->m_RefCount++; 
			EDA_BaseStruct* bs = m_s->EEDrawList; 
			EDA_BaseStruct* bs = m_s->EEDrawList; 
			while(bs){
			while(bs){
				if(bs->Type() ==  DRAW_SHEET_STRUCT_TYPE){
				if(bs->Type() ==  DRAW_SHEET_STRUCT_TYPE){
+11 −0
Original line number Original line Diff line number Diff line
@@ -112,6 +112,15 @@ const wxString EDA_SchComponentStruct::GetRef( DrawSheetList* sheet )
			return m_References[i]; 
			return m_References[i]; 
		}
		}
	}
	}
	//if it was not found in m_Paths array, then see if it is in
	// m_Field[REFERENCE] -- if so, use this as a default for this path.
	// this will happen if we load a version 1 schematic file. 
	// it will also mean that multiple instances of the same sheet by default
	// all have the same component references, but perhaps this is best. 
	if( !m_Field[REFERENCE].m_Text.IsEmpty() ){
		SetRef( sheet, m_Field[REFERENCE].m_Text ); 
		return m_Field[REFERENCE].m_Text; 
	}
	return m_PrefixString; 
	return m_PrefixString; 
}
}


@@ -143,6 +152,8 @@ void EDA_SchComponentStruct::SetRef( DrawSheetList* sheet, wxString ref )
			abs(m_Field[REFERENCE].m_Pos.y - m_Pos.y) > 1000)) {
			abs(m_Field[REFERENCE].m_Pos.y - m_Pos.y) > 1000)) {
		//move it to a reasonable position..
		//move it to a reasonable position..
		m_Field[REFERENCE].m_Pos = m_Pos; 
		m_Field[REFERENCE].m_Pos = m_Pos; 
		m_Field[REFERENCE].m_Pos.x += 50; //a slight offset..
		m_Field[REFERENCE].m_Pos.y += 50; 
	}
	}
	m_Field[REFERENCE].m_Text = ref; //for drawing. 
	m_Field[REFERENCE].m_Text = ref; //for drawing. 
}
}
+2 −0
Original line number Original line Diff line number Diff line
@@ -201,6 +201,8 @@ EDA_SchComponentStruct* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
    if( msg.IsEmpty() )
    if( msg.IsEmpty() )
        msg = wxT( "U" );
        msg = wxT( "U" );
    msg += wxT( "?" );
    msg += wxT( "?" );
	//update the reference -- just the prefix for now. 
	DrawLibItem->SetRef(GetSheet(), msg ); 


    /* Init champ Reference */
    /* Init champ Reference */
    DrawLibItem->m_Field[REFERENCE].m_Pos.x =
    DrawLibItem->m_Field[REFERENCE].m_Pos.x =
+5 −6
Original line number Original line Diff line number Diff line
@@ -164,8 +164,7 @@ void WinEDA_SchematicFrame::ReCreateMenuBar()
                    placeMenu,
                    placeMenu,
                    ID_COMPONENT_BUTT,
                    ID_COMPONENT_BUTT,
                    _("&Component"),
                    _("&Component"),
            _( "Place the component" )
					_("Place a component") );
            );
        item->SetBitmap( add_component_xpm );
        item->SetBitmap( add_component_xpm );
        placeMenu->Append( item );
        placeMenu->Append( item );


Loading