diff --git a/CHANGELOG.txt b/CHANGELOG.txt index e9e84fedcb..214af034d5 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,6 +4,28 @@ KiCad ChangeLog 2010 Please add newer entries at the top, list the date and your name with email address. +2010-dec-21 UPDATE Wayne Stambaugh +================================================================================ +++all + * Doxygen comment warning fixes. + * Coding policy fixes. +++common + * Add clone method to EDA_ITEM object. +++EESchema + * Replace GenCopy() method with Clone() in all items derived from SCH_ITEM. + * Simplify repeat last schematic item with new Clone() method. + * Simplify duplicate schematic item method with new Clone() method. + * Separate objects in sch_items.h/cpp into separate files per object. + + +2010-dec-20, UPDATE Jean-Pierre Charras +================================================================================ +common: + Rename EDA_Rect::Inside to EDA_Rect::Contains + ( EDA_Rect::Inside( const EDA_Rect& aRect ) was very ambiguous ) + Fix some Doxygen warnings and erroneous comments + + 2010-Dec-19 UPDATE Dick Hollenbeck ================================================================================ ++new: diff --git a/common/base_struct.cpp b/common/base_struct.cpp index 2b5ae96bfd..eb66499876 100644 --- a/common/base_struct.cpp +++ b/common/base_struct.cpp @@ -37,6 +37,7 @@ EDA_ITEM::EDA_ITEM( KICAD_T idType ) EDA_ITEM::EDA_ITEM( const EDA_ITEM& base ) { + InitVars(); m_StructType = base.m_StructType; m_Parent = base.m_Parent; m_Son = base.m_Son; @@ -73,6 +74,13 @@ void EDA_ITEM::SetModified() } +EDA_ITEM* EDA_ITEM::doClone() const +{ + wxCHECK_MSG( false, NULL, wxT( "doClone not implemented in derived class " ) + GetClass() + + wxT( ". Bad programmer." ) ); +} + + // see base_struct.h SEARCH_RESULT EDA_ITEM::IterateForward( EDA_ITEM* listStart, INSPECTOR* inspector, @@ -117,9 +125,9 @@ SEARCH_RESULT EDA_ITEM::Visit( INSPECTOR* inspector, const void* testData, return SEARCH_CONTINUE; } - #if defined(DEBUG) + // A function that should have been in wxWidgets std::ostream& operator<<( std::ostream& out, const wxSize& size ) { @@ -136,13 +144,6 @@ std::ostream& operator<<( std::ostream& out, const wxPoint& pt ) } -/** - * Function Show - * is used to output the object tree, currently for debugging only. - * @param nestLevel An aid to prettier tree indenting, and is the level - * of nesting of this object within the overall tree. - * @param os The ostream& to output to. - */ void EDA_ITEM::Show( int nestLevel, std::ostream& os ) const { // XML output: @@ -154,13 +155,6 @@ void EDA_ITEM::Show( int nestLevel, std::ostream& os ) const } -/** - * Function NestedSpace - * outputs nested space for pretty indenting. - * @param nestLevel The nest count - * @param os The ostream&, where to output - * @return std::ostream& - for continuation. - **/ std::ostream& EDA_ITEM::NestedSpace( int nestLevel, std::ostream& os ) { for( int i = 0; iCount(); i++ ) { wxString txt = list->Item( i ); @@ -391,24 +381,10 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, } -/** - * Function DrawOneLineOfText - * Draw a single text line. - * Used to draw each line of this EDA_TextStruct, that can be multiline - * @param aPanel = the current DrawPanel - * @param aDC = the current Device Context - * @param aOffset = draw offset (usually (0,0)) - * @param EDA_Colors aColor = text color - * @param aDrawMode = GR_OR, GR_XOR.., -1 to use the current mode. - * @param aFillMode = FILAIRE, FILLED or SKETCH - * @param EDA_Colors aAnchor_color = anchor color ( UNSPECIFIED_COLOR = do not draw anchor ). - * @param EDA_Colors aText = the single line of text to draw. - * @param EDA_Colors aPos = the position of this line ). - */ void EDA_TextStruct::DrawOneLineOfText( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, EDA_Colors aColor, - int aDrawMode, - GRTraceMode aFillMode, EDA_Colors aAnchor_color, + int aDrawMode, GRTraceMode aFillMode, + EDA_Colors aAnchor_color, wxString& aText, wxPoint aPos ) { int width = m_Thickness; @@ -449,23 +425,20 @@ void EDA_TextStruct::DrawOneLineOfText( WinEDA_DrawPanel* aPanel, wxDC* aDC, if( m_Mirror ) size.x = -size.x; - DrawGraphicText( aPanel, aDC, - aOffset + aPos, aColor, aText, - m_Orient, size, + DrawGraphicText( aPanel, aDC, aOffset + aPos, aColor, aText, m_Orient, size, m_HJustify, m_VJustify, width, m_Italic, m_Bold ); } -/** - * Function GetStyleName - * @return a wwString withe the style name( Normal, Italic, Bold, Bold+Italic) - */ wxString EDA_TextStruct::GetTextStyleName() { int style = 0; + if( m_Italic ) style = 1; + if( m_Bold ) style += 2; + wxString stylemsg[4] = { _("Normal"), _("Italic"), @@ -481,17 +454,14 @@ wxString EDA_TextStruct::GetTextStyleName() /* Class EDA_Rect */ /******************/ -/******************************/ void EDA_Rect::Normalize() -/******************************/ - -// Ensure the height ant width are >= 0 { if( m_Size.y < 0 ) { m_Size.y = -m_Size.y; m_Pos.y -= m_Size.y; } + if( m_Size.x < 0 ) { m_Size.x = -m_Size.x; @@ -500,63 +470,65 @@ void EDA_Rect::Normalize() } - -/** - * Function Move - * Move this rectangle by the aMoveVector value (this is a relative move) - * @param aMoveVector = a wxPoint that is the value to move this rectangle - */ void EDA_Rect::Move( const wxPoint& aMoveVector ) { m_Pos += aMoveVector; } -/* Return TRUE if point is in Rect - * Accept rect size < 0 - */ -bool EDA_Rect::Inside( const wxPoint& point ) const +bool EDA_Rect::Contains( const wxPoint& aPoint ) const { - int rel_posx = point.x - m_Pos.x; - int rel_posy = point.y - m_Pos.y; + wxPoint rel_pos = aPoint - m_Pos; wxSize size = m_Size; if( size.x < 0 ) { size.x = -size.x; - rel_posx += size.x; + rel_pos.x += size.x; } if( size.y < 0 ) { size.y = -size.y; - rel_posy += size.y; + rel_pos.y += size.y; } - return (rel_posx >= 0) && (rel_posy >= 0) && ( rel_posy <= size.y) && ( rel_posx <= size.x); + return (rel_pos.x >= 0) && (rel_pos.y >= 0) && ( rel_pos.y <= size.y) && ( rel_pos.x <= size.x); } - -bool EDA_Rect::Inside( const EDA_Rect& aRect ) const +/* + * return true if aRect is inside me (or on boundaries) + */ +bool EDA_Rect::Contains( const EDA_Rect& aRect ) const { - wxRect rect = aRect; - wxRect me = wxRect(); - - return me.Contains( rect ); + return Contains( aRect.GetOrigin() ) && Contains( aRect.GetEnd() ); } -bool EDA_Rect::Intersects( const EDA_Rect aRect ) const +/* Intersects + * test for a common area between 2 rect. + * return true if at least a common point is found + */ +bool EDA_Rect::Intersects( const EDA_Rect& aRect ) const { // this logic taken from wxWidgets' geometry.cpp file: bool rc; + EDA_Rect me(*this); + EDA_Rect rect(aRect); + me.Normalize(); // ensure size is >= 0 + rect.Normalize(); // ensure size is >= 0 - int left = MAX( m_Pos.x, aRect.m_Pos.x ); - int right = MIN( m_Pos.x + m_Size.x, aRect.m_Pos.x + aRect.m_Size.x ); - int top = MAX( m_Pos.y, aRect.m_Pos.y ); - int bottom = MIN( m_Pos.y + m_Size.y, aRect.m_Pos.y + aRect.m_Size.y ); + // calculate the left common area coordinate: + int left = MAX( me.m_Pos.x, rect.m_Pos.x ); + // calculate the right common area coordinate: + int right = MIN( me.m_Pos.x + m_Size.x, rect.m_Pos.x + rect.m_Size.x ); + // calculate the upper common area coordinate: + int top = MAX( me.m_Pos.y, aRect.m_Pos.y ); + // calculate the lower common area coordinate: + int bottom = MIN( me.m_Pos.y + m_Size.y, rect.m_Pos.y + rect.m_Size.y ); - if( left < right && top < bottom ) + // if a common area exists, it must have a positive (null accepted) size + if( left <= right && top <= bottom ) rc = true; else rc = false; @@ -565,35 +537,14 @@ bool EDA_Rect::Intersects( const EDA_Rect aRect ) const } -/**************************************************/ EDA_Rect& EDA_Rect::Inflate( int aDelta ) -/**************************************************/ - -/** - * Function Inflate - * Inflate "this": move each horizontal edgeand each vertical edge by aDelta - * toward rect outside - * if aDelta is negative, move toward rect inside (deflate) - * Works for positive and negative rect size - * - */ { Inflate( aDelta, aDelta ); return *this; } -/**************************************************/ -EDA_Rect& EDA_Rect::Inflate( wxCoord dx, wxCoord dy ) -/**************************************************/ -/** - * Function Inflate - * Inflate "this": move each horizontal edge by dx and each vertical edge by dy - * toward rect outside - * if dx and/or dy is negative, move toward rect inside (deflate) - * Works for positive and negative rect size - * - */ +EDA_Rect& EDA_Rect::Inflate( wxCoord dx, wxCoord dy ) { if( m_Size.x >= 0 ) { @@ -626,7 +577,6 @@ EDA_Rect& EDA_Rect::Inflate( wxCoord dx, wxCoord dy ) } } - if( m_Size.y >= 0 ) { if( m_Size.y < -2 * dy ) @@ -662,12 +612,6 @@ EDA_Rect& EDA_Rect::Inflate( wxCoord dx, wxCoord dy ) } -/** - * Function Merge - * modifies Position and Size of this in order to contain the given rect - * mainly used to calculate bounding boxes - * @param aRect = given rect to merge with this - */ void EDA_Rect::Merge( const EDA_Rect& aRect ) { Normalize(); // ensure width and height >= 0 @@ -684,12 +628,7 @@ void EDA_Rect::Merge( const EDA_Rect& aRect ) SetEnd( end ); } -/** - * Function Merge - * modifies Position and Size of this in order to contain the given point - * mainly used to calculate bounding boxes - * @param aPoint = given point to merge with this - */ + void EDA_Rect::Merge( const wxPoint& aPoint ) { Normalize(); // ensure width and height >= 0 diff --git a/common/basicframe.cpp b/common/basicframe.cpp index 1652c73424..c92bb9d0ef 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -282,7 +282,7 @@ void WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event ) /* * */ -void WinEDA_BasicFrame::GetKicadAbout( wxCommandEvent& WXUNUSED(event) ) +void WinEDA_BasicFrame::GetKicadAbout( wxCommandEvent& event ) { bool ShowAboutDialog(wxWindow * parent); ShowAboutDialog(this); @@ -364,7 +364,7 @@ static inline const char* KICAD_BUILD_OPTIONS_SIGNATURE() #endif -void WinEDA_BasicFrame::CopyVersionInfoToClipboard( wxCommandEvent& WXUNUSED( event ) ) +void WinEDA_BasicFrame::CopyVersionInfoToClipboard( wxCommandEvent& event ) { if( !wxTheClipboard->Open() ) { diff --git a/common/build_version.cpp b/common/build_version.cpp index 5c83804fb3..8f2d5182aa 100644 --- a/common/build_version.cpp +++ b/common/build_version.cpp @@ -6,7 +6,7 @@ #endif #ifndef KICAD_BUILD_VERSION -#define KICAD_BUILD_VERSION "(2010-12-18 BZR 26xx)" +#define KICAD_BUILD_VERSION "(2010-12-22 BZR 2676)" #endif //#define VERSION_STABILITY "stable" diff --git a/common/class_marker_base.cpp b/common/class_marker_base.cpp index 9177130e53..cdcf4c95c8 100644 --- a/common/class_marker_base.cpp +++ b/common/class_marker_base.cpp @@ -59,6 +59,17 @@ void MARKER_BASE::init() } +MARKER_BASE::MARKER_BASE( const MARKER_BASE& aMarker ) +{ + m_Pos = aMarker.m_Pos; + m_Corners = aMarker.m_Corners; + m_MarkerType = aMarker.m_MarkerType; + m_Color = aMarker.m_Color; + m_ShapeBoundingBox = aMarker.m_ShapeBoundingBox; + m_ScalingFactor = aMarker.m_ScalingFactor; +} + + MARKER_BASE::MARKER_BASE() { m_ScalingFactor = M_SHAPE_SCALE; @@ -118,17 +129,10 @@ bool MARKER_BASE::HitTestMarker( const wxPoint& refPos ) const rel_pos.x /= m_ScalingFactor; rel_pos.y /= m_ScalingFactor; - return m_ShapeBoundingBox.Inside( rel_pos ); + return m_ShapeBoundingBox.Contains( rel_pos ); } -/** - * Function GetBoundingBoxMarker - * returns the orthogonal, bounding box of this object for display purposes. - * This box should be an enclosing perimeter for visible components of this - * object, and the units should be in the pcb or schematic coordinate system. - * It is OK to overestimate the size by a few counts. - */ EDA_Rect MARKER_BASE::GetBoundingBoxMarker() const { wxSize realsize = m_ShapeBoundingBox.GetSize(); @@ -141,15 +145,8 @@ EDA_Rect MARKER_BASE::GetBoundingBoxMarker() const return EDA_Rect( m_Pos, realsize ); } -/**********************************************************************/ void MARKER_BASE::DrawMarker( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode, const wxPoint& aOffset ) -/**********************************************************************/ - -/** - * Function DrawMarker - * The shape is the polygon defined in m_Corners (array of wxPoints) - */ { wxPoint corners[CORNERS_COUNT]; @@ -172,16 +169,11 @@ void MARKER_BASE::DrawMarker( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode } -/** - * Function DisplayMarkerInfo - * Displays the full info of this marker, within an HTML window - */ void MARKER_BASE::DisplayMarkerInfo( WinEDA_DrawFrame* aFrame ) { wxString msg = m_drc.ShowHtml(); - DIALOG_DISPLAY_HTML_TEXT_BASE - infodisplay( (wxWindow*)aFrame, wxID_ANY, _("Marker Info"), - wxGetMousePosition(), wxSize( 550, 140 ) ); + DIALOG_DISPLAY_HTML_TEXT_BASE infodisplay( (wxWindow*)aFrame, wxID_ANY, _( "Marker Info" ), + wxGetMousePosition(), wxSize( 550, 140 ) ); infodisplay.m_htmlWindow->SetPage( msg ); infodisplay.ShowModal(); diff --git a/common/dcsvg.cpp b/common/dcsvg.cpp index 4069ce6d5f..33c26af5a4 100644 --- a/common/dcsvg.cpp +++ b/common/dcsvg.cpp @@ -879,7 +879,7 @@ void wxSVGFileDC::DoDrawIcon( const class wxIcon& myIcon, wxCoord x, wxCoord y ) void wxSVGFileDC::DoDrawBitmap( const class wxBitmap& bmp, wxCoord x, wxCoord y, - bool WXUNUSED ( bTransparent) /*=0*/ ) + bool bTransparent /*=0*/ ) { if( m_graphics_changed ) NewGraphics(); diff --git a/common/drawpanel.cpp b/common/drawpanel.cpp index 8a0ae3963d..3924a4f567 100644 --- a/common/drawpanel.cpp +++ b/common/drawpanel.cpp @@ -251,7 +251,7 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos ) GetScreen()->Unscale( display_rect.m_Size ); #endif - return display_rect.Inside( ref_pos ); + return display_rect.Contains( ref_pos ); } diff --git a/common/gr_basic.cpp b/common/gr_basic.cpp index c6c7122cbe..01fb327844 100644 --- a/common/gr_basic.cpp +++ b/common/gr_basic.cpp @@ -188,7 +188,7 @@ int GRMapY( int y ) */ static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 ) { - if( aClipBox->Inside( x1, y1 ) && aClipBox->Inside( x2, y2 ) ) + if( aClipBox->Contains( x1, y1 ) && aClipBox->Contains( x2, y2 ) ) return false; wxRect rect = *aClipBox; @@ -206,7 +206,7 @@ static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 ) tmpY2 = y2; #endif - if( aClipBox->Inside( x1, y1 ) ) + if( aClipBox->Contains( x1, y1 ) ) { if( x1 == x2 ) /* Vertical line, clip Y. */ { @@ -263,7 +263,7 @@ static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 ) #endif return false; } - else if( aClipBox->Inside( x2, y2 ) ) + else if( aClipBox->Contains( x2, y2 ) ) { if( x1 == x2 ) /* Vertical line, clip Y. */ { @@ -704,7 +704,7 @@ void GRPutPixel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int Color ) void GRSPutPixel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int Color ) { - if( ClipBox && !ClipBox->Inside( x, y ) ) + if( ClipBox && !ClipBox->Contains( x, y ) ) return; GRSetColorPen( DC, Color ); diff --git a/common/hotkeys_basic.cpp b/common/hotkeys_basic.cpp index e37d6c6e4d..43b5ffb21f 100644 --- a/common/hotkeys_basic.cpp +++ b/common/hotkeys_basic.cpp @@ -170,15 +170,14 @@ wxString ReturnKeyNameFromKeyCode( int aKeycode, bool* aIsFound ) } -/** - * Function AddHotkeyName +/* AddHotkeyName * Add the key name from the Command id value ( m_Idcommand member value) - * @param aText = a wxString. returns aText + key name - * @param aList = pointer to a Ki_HotkeyInfo list of commands - * @param aCommandId = Command Id value - * @param aIsShortCut = true to add (active shortcuts in menus) + * aText = a wxString. returns aText + key name + * aList = pointer to a Ki_HotkeyInfo list of commands + * aCommandId = Command Id value + * aIsShortCut = true to add (active shortcuts in menus) * = false to add <(keyname)> - * @return a wxString (aTest + key name) if key found or aText without modification + * Return a wxString (aTest + key name) if key found or aText without modification */ wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList, int aCommandId, bool aIsShortCut ) @@ -200,15 +199,14 @@ wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList, } -/** - * Function AddHotkeyName +/* AddHotkeyName * Add the key name from the Command id value ( m_Idcommand member value) - * @param aText = a wxString. returns aText + key name - * @param aList = pointer to a Ki_HotkeyInfoSectionDescriptor DescrList of commands - * @param aCommandId = Command Id value - * @param aIsShortCut = true to add (active shortcuts in menus) + * aText = a wxString. returns aText + key name + * aList = pointer to a Ki_HotkeyInfoSectionDescriptor DescrList of commands + * aCommandId = Command Id value + * aIsShortCut = true to add (active shortcuts in menus) * = false to add <(keyname)> - * @return a wxString (aTest + key name) if key found or aText without modification + * Return a wxString (aText + key name) if key found or aText without modification */ wxString AddHotkeyName( const wxString& aText, struct Ki_HotkeyInfoSectionDescriptor* aDescList, @@ -325,13 +323,9 @@ int ReturnKeyCodeFromKeyName( const wxString& keyname ) } -/** - * Function DisplayHotkeyList +/* DisplayHotkeyList * Displays the current hotkey list - * @param aFrame = current active frame - * @param aList = pointer to a Ki_HotkeyInfoSectionDescriptor list - *(Null terminated) - * @return none + * aList = a Ki_HotkeyInfoSectionDescriptor list(Null terminated) */ void DisplayHotkeyList( WinEDA_DrawFrame* aFrame, struct Ki_HotkeyInfoSectionDescriptor* aDescList ) @@ -478,7 +472,6 @@ int WinEDA_BasicFrame::ReadHotkeyConfigFile( return 1; } - void ReadHotkeyConfig( const wxString& Appname, struct Ki_HotkeyInfoSectionDescriptor* aDescList ) { @@ -496,11 +489,9 @@ void ReadHotkeyConfig( const wxString& Appname, ParseHotkeyConfig( data, aDescList ); } - -/** - * Function ReadHotkeyConfig +/* Function ReadHotkeyConfig * Read configuration data and fill the current hotkey list with hotkeys - * @param aDescList = current hotkey list descr. to initialise. + * aDescList is the current hotkey list descr. to initialise. */ int WinEDA_BasicFrame::ReadHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aDescList ) { @@ -509,16 +500,14 @@ int WinEDA_BasicFrame::ReadHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* } -/** - * Function ParseHotkeyConfig +/* Function ParseHotkeyConfig * the input format is: shortcut "key" "function" * lines starting by # are ignored (comments) - * lines like [xxx] are tags (example: [common] or [libedit] which identify - * sections + * lines like [xxx] are tags (example: [common] or [libedit] which identify sections */ void ParseHotkeyConfig( const wxString& data, - struct Ki_HotkeyInfoSectionDescriptor* DescList ) + struct Ki_HotkeyInfoSectionDescriptor* aDescList ) { /* Read the config */ wxStringTokenizer tokenizer( data, L"\r\n", wxTOKEN_STRTOK ); @@ -536,7 +525,7 @@ void ParseHotkeyConfig( if( line_type[0] == '[' ) // A tag is found. search infos in list { CurrentHotkeyList = 0; - Ki_HotkeyInfoSectionDescriptor* DList = DescList; + Ki_HotkeyInfoSectionDescriptor* DList = aDescList; for( ; DList->m_HK_InfoList; DList++ ) { if( *DList->m_SectionTag == line_type ) @@ -639,8 +628,7 @@ void WinEDA_BasicFrame::ExportHotkeyConfigToFile( } -/** add hotkey config options submenu to a menu - * @param menu : root menu +/* add hotkey config options submenu to aMenu */ void AddHotkeyConfigMenu( wxMenu* aMenu ) { diff --git a/common/sch_item_struct.cpp b/common/sch_item_struct.cpp index a4ee718214..d0e558bc8f 100644 --- a/common/sch_item_struct.cpp +++ b/common/sch_item_struct.cpp @@ -29,6 +29,13 @@ SCH_ITEM::SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType ) : } +SCH_ITEM::SCH_ITEM( const SCH_ITEM& aItem ) : + EDA_ITEM( aItem ) +{ + m_Layer = aItem.m_Layer; +} + + SCH_ITEM::~SCH_ITEM() { // Do not let the connections container go out of scope with any ojbects or they @@ -101,5 +108,5 @@ bool SCH_ITEM::IsConnected( const wxPoint& aPosition ) const if( m_Flags & STRUCT_DELETED || m_Flags & SKIP_STRUCT ) return false; - return DoIsConnected( aPosition ); + return doIsConnected( aPosition ); } diff --git a/cvpcb/cvpcb.cpp b/cvpcb/cvpcb.cpp index 439fef2586..4519ef9521 100644 --- a/cvpcb/cvpcb.cpp +++ b/cvpcb/cvpcb.cpp @@ -36,14 +36,16 @@ const wxString FootprintAliasFileWildcard( _( "Kicad footprint alias files (*.eq const wxString titleLibLoadError( _( "Library Load Error" ) ); -/* MacOSX: Needed for file association +/* + * MacOSX: Needed for file association * http://wiki.wxwidgets.org/WxMac-specific_topics */ -void WinEDA_App::MacOpenFile(const wxString &fileName) { +void WinEDA_App::MacOpenFile(const wxString &fileName) +{ wxFileName filename = fileName; wxString oldPath; WinEDA_CvpcbFrame * frame = ((WinEDA_CvpcbFrame*)GetTopWindow()); - + if(!filename.FileExists()) return; diff --git a/cvpcb/menubar.cpp b/cvpcb/menubar.cpp index e1a8ad919e..10f056e938 100644 --- a/cvpcb/menubar.cpp +++ b/cvpcb/menubar.cpp @@ -1,6 +1,6 @@ -/** - * @file menucfg.cpp - * (Re)Create the CvPCB main MenuBar +/* + * menubar.cpp + * Build the CvPCB MenuBar */ #include "fctsys.h" #include "appl_wxstruct.h" diff --git a/cvpcb/setvisu.cpp b/cvpcb/setvisu.cpp index ceba06dcca..51960609ab 100644 --- a/cvpcb/setvisu.cpp +++ b/cvpcb/setvisu.cpp @@ -108,11 +108,10 @@ void DISPLAY_FOOTPRINTS_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) /* * Redraw the BOARD items but not cursors, axis or grid. */ -void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* DC, - int aDrawMode, const wxPoint& offset ) +void BOARD::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode, const wxPoint& aOffset ) { if( m_Modules ) { - m_Modules->Draw( aPanel, DC, GR_COPY ); + m_Modules->Draw( aPanel, aDC, GR_COPY ); } } diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index a489be7834..9897ecd1db 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -115,10 +115,14 @@ set(EESCHEMA_SRCS operations_on_items_lists.cpp pinedit.cpp plot.cpp + sch_bus_entry.cpp sch_component.cpp sch_field.cpp sch_items.cpp + sch_line.cpp sch_marker.cpp + sch_no_connect.cpp + sch_polyline.cpp sch_screen.cpp sch_sheet.cpp sch_sheet_path.cpp diff --git a/eeschema/block.cpp b/eeschema/block.cpp index da2f71de53..639f0bd4fd 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -16,8 +16,11 @@ #include "class_library.h" #include "lib_pin.h" #include "protos.h" +#include "sch_bus_entry.h" #include "sch_marker.h" #include "sch_items.h" +#include "sch_line.h" +#include "sch_no_connect.h" #include "sch_text.h" #include "sch_component.h" #include "sch_sheet.h" @@ -37,9 +40,9 @@ void DuplicateItemsInList( SCH_SCREEN* screen, static void CollectStructsToDrag( SCH_SCREEN* screen ); static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition ); -static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, +static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aComponent, wxPoint& aPosition, - bool aSearchFirst ); + LIB_PIN* aPin ); static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList ); @@ -226,6 +229,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) } if( DrawPanel->ManageCurseur != NULL ) + { switch( block->m_Command ) { case BLOCK_IDLE: @@ -234,14 +238,14 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) case BLOCK_DRAG: /* Drag */ BreakSegmentOnJunction( GetScreen() ); - + // fall through case BLOCK_ROTATE: case BLOCK_MIRROR_X: case BLOCK_MIRROR_Y: case BLOCK_MOVE: /* Move */ case BLOCK_COPY: /* Copy */ PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() ); - + // fall through case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ if( block->GetCount() ) { @@ -301,6 +305,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) case BLOCK_ABORT: /* not executed here */ break; } + } if( block->m_Command == BLOCK_ABORT ) { @@ -595,7 +600,8 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC ) } -/* creates the list of items found when a drag block is initiated. +/* Set in m_BlockLocate.m_ItemsSelection items members .m_Flags to SELECTED + * Creates the list of items found when a drag block is initiated. * items are those selected in window block an some items outside this area but * connected to a selected item (connected wires to a component or an entry ) */ @@ -624,14 +630,14 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) /* Remove the displacement of segment and undo the selection. */ for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ ) { - Struct = (SCH_ITEM*)(SCH_ITEM*) pickedlist->GetPickedItem( ii ); + Struct = (SCH_ITEM*)pickedlist->GetPickedItem( ii ); if( Struct->Type() == SCH_LINE_T ) { SegmStruct = (SCH_LINE*) Struct; - if( !screen->m_BlockLocate.Inside( SegmStruct->m_Start ) ) + if( !screen->m_BlockLocate.Contains( SegmStruct->m_Start ) ) SegmStruct->m_Flags |= STARTPOINT; - if( !screen->m_BlockLocate.Inside( SegmStruct->m_End ) ) + if( !screen->m_BlockLocate.Contains( SegmStruct->m_End ) ) SegmStruct->m_Flags |= ENDPOINT; // Save m_Flags for Undo/redo drag operations: @@ -642,17 +648,16 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) /* Search for other items to drag. They are end wires connected to selected * items */ - for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ ) { - Struct = (SCH_ITEM*)(SCH_ITEM*) pickedlist->GetPickedItem( ii ); + Struct = (SCH_ITEM*)pickedlist->GetPickedItem( ii ); if( ( Struct->Type() == SCH_LABEL_T ) || ( Struct->Type() == SCH_GLOBAL_LABEL_T ) || ( Struct->Type() == SCH_HIERARCHICAL_LABEL_T ) ) { #undef STRUCT #define STRUCT ( (SCH_TEXT*) Struct ) - if( !screen->m_BlockLocate.Inside( STRUCT->m_Pos ) ) + if( !screen->m_BlockLocate.Contains( STRUCT->m_Pos ) ) { AddPickedItem( screen, STRUCT->m_Pos ); } @@ -661,20 +666,20 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) if( Struct->Type() == SCH_COMPONENT_T ) { // Add all pins of the selected component to list - LIB_PIN* pin; wxPoint pos; - pin = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos, true ); + LIB_PIN* pin = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos, NULL ); while( pin ) { - if( !screen->m_BlockLocate.Inside( pos ) ) + if( !screen->m_BlockLocate.Contains( pos ) ) { // This pin is outside area, - // but because it it the pin of a selected component + // but because it is a pin of a selected component // we must also select connected items to this pin + // and mainly wires AddPickedItem( screen, pos ); } - pin = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos, false ); + pin = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos, pin ); } } @@ -774,7 +779,6 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) { Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT; Struct->m_Flags &= ~STARTPOINT; - // Save m_Flags for Undo/redo drag operations: picker.m_PickerFlags = Struct->m_Flags; pickedlist->PushItem( picker ); @@ -783,7 +787,6 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) { Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT; Struct->m_Flags &= ~ENDPOINT; - // Save m_Flags for Undo/redo drag operations: picker.m_PickerFlags = Struct->m_Flags; pickedlist->PushItem( picker ); @@ -856,53 +859,45 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) /** GetNextPinPosition() * calculate position of the "next" pin of the aDrawLibItem component - * @param aDrawLibItem = component to test. + * @param aComponent = component to test. * @param aPosition = the calculated pin position, according to the component * orientation and position * @param aSearchFirst = if true, search for the first pin * @return a pointer to the pin */ -static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, +static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aComponent, wxPoint& aPosition, - bool aSearchFirst ) + LIB_PIN* aPin ) { static LIB_COMPONENT* Entry; - static int Multi, convert; - TRANSFORM transform; - static wxPoint CmpPosition; - static LIB_PIN* Pin; - if( aSearchFirst ) + if( aPin == NULL ) { - Entry = CMP_LIBRARY::FindLibraryComponent( aDrawLibItem->GetLibName() ); + Entry = CMP_LIBRARY::FindLibraryComponent( aComponent->GetLibName() ); if( Entry == NULL ) return NULL; - - Pin = Entry->GetNextPin(); - Multi = aDrawLibItem->GetUnit(); - convert = aDrawLibItem->GetConvert(); - CmpPosition = aDrawLibItem->m_Pos; - transform = aDrawLibItem->GetTransform(); } - else - Pin = Entry->GetNextPin( Pin ); - for( ; Pin != NULL; Pin = Entry->GetNextPin( Pin ) ) + aPin = Entry->GetNextPin( aPin ); + + int multi = aComponent->GetUnit(); + int convert = aComponent->GetConvert(); + for( ; aPin != NULL; aPin = Entry->GetNextPin( aPin ) ) { - wxASSERT( Pin->Type() == LIB_PIN_T ); + wxASSERT( aPin->Type() == LIB_PIN_T ); /* Skip items not used for this part */ - if( Multi && Pin->GetUnit() && ( Pin->GetUnit() != Multi ) ) + if( multi && aPin->GetUnit() && ( aPin->GetUnit() != multi ) ) continue; - if( convert && Pin->GetConvert() && ( Pin->GetConvert() != convert ) ) + if( convert && aPin->GetConvert() && ( aPin->GetConvert() != convert ) ) continue; /* Calculate the pin position (according to the component orientation) */ - aPosition = DefaultTransform.TransformCoordinate( Pin->GetPosition() ) + CmpPosition; - return Pin; + aPosition = aComponent->GetPinPhysicalPosition( aPin ); + return aPin; } return NULL; diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index 4b3ca8329a..dfd6f14aaa 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -14,16 +14,18 @@ #include "lib_pin.h" #include "general.h" #include "protos.h" +#include "sch_bus_entry.h" #include "sch_items.h" +#include "sch_line.h" +#include "sch_no_connect.h" +#include "sch_polyline.h" #include "sch_text.h" #include "sch_component.h" #include "sch_sheet.h" /* Routines Locales */ -static void Show_Polyline_in_Ghost( WinEDA_DrawPanel* panel, - wxDC* DC, - bool erase ); +static void Show_Polyline_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC ); static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer ); static bool IsJunctionNeeded( SCH_EDIT_FRAME* frame, wxPoint& pos ); @@ -172,7 +174,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) if( g_HVLines ) // We need 2 segments to go from a given start pin to an end point { - nextsegment = newsegment->GenCopy(); + nextsegment = new SCH_LINE( *newsegment ); nextsegment->m_Flags = IS_NEW; newsegment->SetNext( nextsegment ); nextsegment->SetBack( newsegment ); @@ -220,7 +222,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) /* Create a new segment, and chain it after the current new segment */ if( nextsegment ) { - newsegment = nextsegment->GenCopy(); + newsegment = new SCH_LINE( *nextsegment ); nextsegment->m_Start = newsegment->m_End; nextsegment->SetNext( NULL ); nextsegment->SetBack( newsegment ); @@ -229,7 +231,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) } else { - newsegment = oldsegment->GenCopy(); + newsegment = new SCH_LINE( *oldsegment ); newsegment->m_Start = oldsegment->m_End; } @@ -332,6 +334,7 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC ) if( !g_ItemToRepeat ) g_ItemToRepeat = segment; } + segment->m_Flags = 0; segment = segment->Next(); } @@ -372,7 +375,6 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC ) item = item->Next(); } - DrawPanel->CursorOn( DC ); // Display schematic cursor SaveCopyInUndoList( s_OldWiresList, UR_WIRE_IMAGE ); @@ -442,6 +444,7 @@ static void Show_Polyline_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool eras GRSetDrawMode( DC, g_XorMode ); int idx = NewPoly->GetCornerCount() - 1; + if( g_HVLines ) { /* Coerce the line to vertical or horizontal one: */ @@ -571,111 +574,30 @@ static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC ) */ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC ) { - wxPoint new_pos; - if( g_ItemToRepeat == NULL ) return; - switch( g_ItemToRepeat->Type() ) + g_ItemToRepeat = g_ItemToRepeat->Clone(); + + if( g_ItemToRepeat->Type() == SCH_COMPONENT_T ) // If repeat component then put in move mode { - case SCH_JUNCTION_T: - #undef STRUCT - #define STRUCT ( (SCH_JUNCTION*) g_ItemToRepeat ) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Pos += g_RepeatStep; - new_pos = STRUCT->m_Pos; - break; - - case SCH_NO_CONNECT_T: - #undef STRUCT - #define STRUCT ( (SCH_NO_CONNECT*) g_ItemToRepeat ) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Pos += g_RepeatStep; - new_pos = STRUCT->m_Pos; - break; - - case SCH_TEXT_T: - #undef STRUCT - #define STRUCT ( (SCH_TEXT*) g_ItemToRepeat ) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Pos += g_RepeatStep; - new_pos = STRUCT->m_Pos; - IncrementLabelMember( STRUCT->m_Text ); - break; - - - case SCH_LABEL_T: - #undef STRUCT - #define STRUCT ( (SCH_LABEL*) g_ItemToRepeat ) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Pos += g_RepeatStep; - new_pos = STRUCT->m_Pos; - IncrementLabelMember( STRUCT->m_Text ); - break; - - - case SCH_HIERARCHICAL_LABEL_T: - #undef STRUCT - #define STRUCT ( (SCH_HIERLABEL*) g_ItemToRepeat ) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Pos += g_RepeatStep; - new_pos = STRUCT->m_Pos; - IncrementLabelMember( STRUCT->m_Text ); - break; - - case SCH_GLOBAL_LABEL_T: - #undef STRUCT - #define STRUCT ( (SCH_GLOBALLABEL*) g_ItemToRepeat ) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Pos += g_RepeatStep; - new_pos = STRUCT->m_Pos; - IncrementLabelMember( STRUCT->m_Text ); - break; - - case SCH_LINE_T: - #undef STRUCT - #define STRUCT ( (SCH_LINE*) g_ItemToRepeat ) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Start += g_RepeatStep; - new_pos = STRUCT->m_Start; - STRUCT->m_End += g_RepeatStep; - break; - - case SCH_BUS_ENTRY_T: - #undef STRUCT - #define STRUCT ( (SCH_BUS_ENTRY*) g_ItemToRepeat ) - g_ItemToRepeat = STRUCT->GenCopy(); - STRUCT->m_Pos += g_RepeatStep; - new_pos = STRUCT->m_Pos; - break; - - case SCH_COMPONENT_T: // In repeat command the new component is put - // in move mode - #undef STRUCT - #define STRUCT ( (SCH_COMPONENT*) g_ItemToRepeat ) - - // Create the duplicate component, position = mouse cursor - g_ItemToRepeat = STRUCT->GenCopy(); - new_pos.x = GetScreen()->m_Curseur.x - STRUCT->m_Pos.x; - new_pos.y = GetScreen()->m_Curseur.y - STRUCT->m_Pos.y; - STRUCT->m_Pos = GetScreen()->m_Curseur; - STRUCT->m_Flags = IS_NEW; - STRUCT->m_TimeStamp = GetTimeStamp(); - - for( int ii = 0; ii < STRUCT->GetFieldCount(); ii++ ) - { - STRUCT->GetField( ii )->m_Pos += new_pos; - } - - RedrawOneStruct( DrawPanel, DC, STRUCT, g_XorMode ); - StartMovePart( STRUCT, DC ); + wxPoint pos = GetScreen()->m_Curseur - ( (SCH_COMPONENT*) g_ItemToRepeat )->m_Pos; + g_ItemToRepeat->m_Flags = IS_NEW; + ( (SCH_COMPONENT*) g_ItemToRepeat )->m_TimeStamp = GetTimeStamp(); + g_ItemToRepeat->Move( pos ); + RedrawOneStruct( DrawPanel, DC, g_ItemToRepeat, g_XorMode ); + StartMovePart( (SCH_COMPONENT*) g_ItemToRepeat, DC ); return; - break; + } - default: - g_ItemToRepeat = NULL; - DisplayError( this, wxT( "Repeat Type Error" ), 10 ); - break; + g_ItemToRepeat->Move( wxPoint( g_RepeatStep.GetWidth(), g_RepeatStep.GetHeight() ) ); + + if( g_ItemToRepeat->Type() == SCH_TEXT_T + || g_ItemToRepeat->Type() == SCH_LABEL_T + || g_ItemToRepeat->Type() == SCH_HIERARCHICAL_LABEL_T + || g_ItemToRepeat->Type() == SCH_GLOBAL_LABEL_T ) + { + ( (SCH_TEXT*) g_ItemToRepeat )->IncrementLabel(); } if( g_ItemToRepeat ) @@ -686,9 +608,6 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC ) RedrawOneStruct( DrawPanel, DC, g_ItemToRepeat, GR_DEFAULT_DRAWMODE ); SaveCopyInUndoList( g_ItemToRepeat, UR_NEW ); g_ItemToRepeat->m_Flags = 0; - -// GetScreen()->Curseur = new_pos; -// DrawPanel->MouseTo( DrawPanel->CursorScreenPosition() ); } } @@ -702,6 +621,7 @@ void IncrementLabelMember( wxString& name ) long number = 0; ii = name.Len() - 1; nn = 0; + if( !isdigit( name.GetChar( ii ) ) ) return; @@ -712,6 +632,7 @@ void IncrementLabelMember( wxString& name ) ii++; /* digits are starting at ii position */ wxString litt_number = name.Right( nn ); + if( litt_number.ToLong( &number ) ) { number += g_RepeatDeltaLabel; @@ -778,11 +699,13 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer ) itempos = LibItem->GetScreenCoord( pin->GetPosition() ); itempos.x += LibItem->m_Pos.x; itempos.y += LibItem->m_Pos.y; + if( ( itempos.x == pos.x ) && ( itempos.y == pos.y ) ) return TRUE; } item = PickStruct( pos, screen, WIREITEM ); + if( item ) return TRUE; diff --git a/eeschema/busentry.cpp b/eeschema/busentry.cpp index 9f79cb4a00..8a3f997461 100644 --- a/eeschema/busentry.cpp +++ b/eeschema/busentry.cpp @@ -13,7 +13,7 @@ #include "general.h" #include "protos.h" -#include "sch_items.h" +#include "sch_bus_entry.h" static int s_LastShape = '\\'; @@ -85,7 +85,7 @@ void SCH_EDIT_FRAME::StartMoveBusEntry( SCH_BUS_ENTRY* BusEntry, wxDC* DC ) if( (BusEntry->m_Flags & IS_NEW) == 0 ) // not already in edit, save shape { delete g_ItemToUndoCopy; - g_ItemToUndoCopy = BusEntry->GenCopy(); + g_ItemToUndoCopy = BusEntry->Clone(); } BusEntry->m_Flags |= IS_MOVED; diff --git a/eeschema/cleanup.cpp b/eeschema/cleanup.cpp index 7e2e84846e..d5dae8c0c1 100644 --- a/eeschema/cleanup.cpp +++ b/eeschema/cleanup.cpp @@ -12,7 +12,9 @@ #include "general.h" #include "protos.h" #include "netlist.h" +#include "sch_bus_entry.h" #include "sch_items.h" +#include "sch_line.h" /* Routine to start/end segment (BUS or wires) on junctions. @@ -91,11 +93,11 @@ void BreakSegment( SCH_SCREEN* aScreen, wxPoint aBreakpoint ) * Segment connecte: doit etre coupe en 2 si px,py * n'est * pas une extremite */ - if( ( segment->m_Start == aBreakpoint ) - || ( segment->m_End == aBreakpoint ) ) + if( ( segment->m_Start == aBreakpoint ) || ( segment->m_End == aBreakpoint ) ) continue; + /* Here we must cut the segment into 2. */ - NewSegment = segment->GenCopy(); + NewSegment = new SCH_LINE( *segment ); NewSegment->m_Start = aBreakpoint; segment->m_End = NewSegment->m_Start; NewSegment->SetNext( segment->Next() ); diff --git a/eeschema/delete.cpp b/eeschema/delete.cpp index fb71dc9051..cddf04830c 100644 --- a/eeschema/delete.cpp +++ b/eeschema/delete.cpp @@ -12,6 +12,7 @@ #include "protos.h" #include "sch_marker.h" #include "sch_items.h" +#include "sch_line.h" #include "sch_sheet.h" #include "sch_text.h" diff --git a/eeschema/dialogs/dialog_color_config.cpp b/eeschema/dialogs/dialog_color_config.cpp index 22a997ba11..52ada03a72 100644 --- a/eeschema/dialogs/dialog_color_config.cpp +++ b/eeschema/dialogs/dialog_color_config.cpp @@ -297,7 +297,7 @@ void DIALOG_COLOR_CONFIG::UpdateLayerSettings() } -void DIALOG_COLOR_CONFIG::OnOkClick( wxCommandEvent& WXUNUSED( event ) ) +void DIALOG_COLOR_CONFIG::OnOkClick( wxCommandEvent& event ) { UpdateLayerSettings(); m_Parent->DrawPanel->Refresh(); @@ -305,13 +305,13 @@ void DIALOG_COLOR_CONFIG::OnOkClick( wxCommandEvent& WXUNUSED( event ) ) } -void DIALOG_COLOR_CONFIG::OnCancelClick( wxCommandEvent& WXUNUSED( event ) ) +void DIALOG_COLOR_CONFIG::OnCancelClick( wxCommandEvent& event ) { EndModal( -1 ); } -void DIALOG_COLOR_CONFIG::OnApplyClick( wxCommandEvent& WXUNUSED( event ) ) +void DIALOG_COLOR_CONFIG::OnApplyClick( wxCommandEvent& event ) { UpdateLayerSettings(); m_Parent->DrawPanel->Refresh(); diff --git a/eeschema/dialogs/dialog_edit_component_in_lib.cpp b/eeschema/dialogs/dialog_edit_component_in_lib.cpp index 6b5c12269f..83cf450c3f 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_lib.cpp @@ -239,7 +239,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) } -void DIALOG_EDIT_COMPONENT_IN_LIBRARY::CopyDocToAlias( wxCommandEvent& WXUNUSED (event) ) +void DIALOG_EDIT_COMPONENT_IN_LIBRARY::CopyDocToAlias( wxCommandEvent& event ) { if( m_Parent == NULL ) return; @@ -261,7 +261,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::CopyDocToAlias( wxCommandEvent& WXUNUSED } -void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllAliasOfPart( wxCommandEvent& WXUNUSED (event) ) +void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllAliasOfPart( wxCommandEvent& event ) { if( m_PartAliasListCtrl->FindString( m_Parent->GetAliasName() ) != wxNOT_FOUND ) { @@ -284,7 +284,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllAliasOfPart( wxCommandEvent& WXU /* Add a new name to the alias list box * New name cannot be the root name, and must not exists */ -void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& WXUNUSED (event) ) +void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& event ) { wxString aliasname; LIB_COMPONENT* component = m_Parent->GetComponent(); @@ -324,7 +324,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& WXUNUSED } -void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAliasOfPart( wxCommandEvent& WXUNUSED (event) ) +void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAliasOfPart( wxCommandEvent& event ) { wxString aliasname = m_PartAliasListCtrl->GetStringSelection(); @@ -444,7 +444,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::BrowseAndSelectDocFile( wxCommandEvent& e } -void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllFootprintFilter( wxCommandEvent& WXUNUSED (event) ) +void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllFootprintFilter( wxCommandEvent& event ) { if( IsOK( this, _( "Ok to Delete FootprintFilter LIST" ) ) ) { @@ -458,7 +458,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllFootprintFilter( wxCommandEvent& /* Add a new name to the footprint filter list box * Obvioulsy, cannot be void */ -void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& WXUNUSED (event) ) +void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& event ) { wxString Line; LIB_COMPONENT* component = m_Parent->GetComponent(); @@ -494,7 +494,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& WXUNU } -void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteOneFootprintFilter( wxCommandEvent& WXUNUSED( event ) ) +void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteOneFootprintFilter( wxCommandEvent& event ) { LIB_COMPONENT* component = m_Parent->GetComponent(); int ii = m_FootprintFilterListBox->GetSelection(); diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index 3debdf5be2..e18925a6f4 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -578,6 +578,22 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel() m_StyleRadioBox->SetSelection( style ); + // Select the right text justification + if( field.m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) + m_FieldHJustifyCtrl->SetSelection(0); + else if( field.m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) + m_FieldHJustifyCtrl->SetSelection(2); + else + m_FieldHJustifyCtrl->SetSelection(1); + + if( field.m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM ) + m_FieldVJustifyCtrl->SetSelection(0); + else if( field.m_VJustify == GR_TEXT_VJUSTIFY_TOP ) + m_FieldVJustifyCtrl->SetSelection(2); + else + m_FieldVJustifyCtrl->SetSelection(1); + + fieldNameTextCtrl->SetValue( field.m_Name ); // the names of the fixed fields are not editable, others are. @@ -657,6 +673,19 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField() rotateCheckBox->SetValue( field.m_Orient == TEXT_ORIENT_VERT ); + // Copy the text justification + GRTextHorizJustifyType hjustify[3] = { + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_CENTER, + GR_TEXT_HJUSTIFY_RIGHT + }; + + GRTextVertJustifyType vjustify[3] = { + GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_CENTER, + GR_TEXT_VJUSTIFY_TOP + }; + + field.m_HJustify = hjustify[m_FieldHJustifyCtrl->GetSelection()]; + field.m_VJustify = vjustify[m_FieldVJustifyCtrl->GetSelection()]; field.m_Name = fieldNameTextCtrl->GetValue(); /* Void fields texts for REFERENCE and VALUE (value is the name of the diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.cpp index 636fbd8813..12eebbdb73 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 16 2008) +// C++ code generated with wxFormBuilder (version Sep 8 2010) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -29,7 +29,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( int unitChoiceNChoices = sizeof( unitChoiceChoices ) / sizeof( wxString ); unitChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, unitChoiceNChoices, unitChoiceChoices, 0 ); unitChoice->SetSelection( 0 ); - unitSizer->Add( unitChoice, 1, wxALL|wxEXPAND, 5 ); + unitSizer->Add( unitChoice, 0, wxALL|wxEXPAND, 5 ); optionsSizer->Add( unitSizer, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 8 ); @@ -42,9 +42,9 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( orientationRadioBox->SetSelection( 0 ); orientationRadioBox->SetToolTip( _("Select if the component is to be rotated when drawn") ); - orientationSizer->Add( orientationRadioBox, 1, wxALL, 8 ); + orientationSizer->Add( orientationRadioBox, 1, wxALL|wxEXPAND, 8 ); - optionsSizer->Add( orientationSizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 0 ); + optionsSizer->Add( orientationSizer, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 0 ); wxBoxSizer* mirrorSizer; mirrorSizer = new wxBoxSizer( wxHORIZONTAL ); @@ -57,7 +57,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( mirrorSizer->Add( mirrorRadioBox, 1, wxALL, 8 ); - optionsSizer->Add( mirrorSizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 0 ); + optionsSizer->Add( mirrorSizer, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 0 ); wxStaticBoxSizer* chipnameSizer; chipnameSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Chip Name") ), wxHORIZONTAL ); @@ -71,7 +71,6 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( optionsSizer->Add( chipnameSizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 8 ); convertCheckBox = new wxCheckBox( this, wxID_ANY, _("Convert"), wxDefaultPosition, wxDefaultSize, 0 ); - convertCheckBox->SetToolTip( _("Use the alternate shape of this component.\nFor gates, this is the \"De Morgan\" conversion") ); optionsSizer->Add( convertCheckBox, 0, wxALL, 8 ); @@ -113,11 +112,28 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( gridStaticBoxSizer->Add( moveUpButton, 0, wxALL|wxEXPAND, 5 ); - fieldsSizer->Add( gridStaticBoxSizer, 5, wxALL|wxEXPAND, 8 ); + fieldsSizer->Add( gridStaticBoxSizer, 5, wxEXPAND|wxRIGHT|wxLEFT, 8 ); wxBoxSizer* fieldEditBoxSizer; fieldEditBoxSizer = new wxBoxSizer( wxVERTICAL ); + wxStaticBoxSizer* sbSizerOptions; + sbSizerOptions = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options") ), wxHORIZONTAL ); + + wxString m_FieldHJustifyCtrlChoices[] = { _("Align left"), _("Align center"), _("Align right") }; + int m_FieldHJustifyCtrlNChoices = sizeof( m_FieldHJustifyCtrlChoices ) / sizeof( wxString ); + m_FieldHJustifyCtrl = new wxRadioBox( this, wxID_ANY, _("Horiz. Justify"), wxDefaultPosition, wxDefaultSize, m_FieldHJustifyCtrlNChoices, m_FieldHJustifyCtrlChoices, 1, wxRA_SPECIFY_COLS ); + m_FieldHJustifyCtrl->SetSelection( 1 ); + sbSizerOptions->Add( m_FieldHJustifyCtrl, 1, wxRIGHT|wxLEFT, 5 ); + + wxString m_FieldVJustifyCtrlChoices[] = { _("Align bottom"), _("Align center"), _("Align top") }; + int m_FieldVJustifyCtrlNChoices = sizeof( m_FieldVJustifyCtrlChoices ) / sizeof( wxString ); + m_FieldVJustifyCtrl = new wxRadioBox( this, wxID_ANY, _("Vert. Justify"), wxDefaultPosition, wxDefaultSize, m_FieldVJustifyCtrlNChoices, m_FieldVJustifyCtrlChoices, 1, wxRA_SPECIFY_COLS ); + m_FieldVJustifyCtrl->SetSelection( 1 ); + sbSizerOptions->Add( m_FieldVJustifyCtrl, 1, wxRIGHT|wxLEFT, 5 ); + + fieldEditBoxSizer->Add( sbSizerOptions, 0, wxEXPAND, 5 ); + wxStaticBoxSizer* visibilitySizer; visibilitySizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Visibility") ), wxHORIZONTAL ); @@ -125,13 +141,11 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( bShowRotateSizer = new wxBoxSizer( wxVERTICAL ); showCheckBox = new wxCheckBox( this, wxID_ANY, _("Show"), wxDefaultPosition, wxDefaultSize, 0 ); - showCheckBox->SetToolTip( _("Check if you want this field visible") ); bShowRotateSizer->Add( showCheckBox, 0, wxALL, 5 ); rotateCheckBox = new wxCheckBox( this, wxID_ANY, _("Rotate"), wxDefaultPosition, wxDefaultSize, 0 ); - rotateCheckBox->SetToolTip( _("Check if you want this field's text rotated 90 degrees") ); bShowRotateSizer->Add( rotateCheckBox, 0, wxALL, 5 ); @@ -146,7 +160,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( visibilitySizer->Add( m_StyleRadioBox, 1, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - fieldEditBoxSizer->Add( visibilitySizer, 0, wxEXPAND, 5 ); + fieldEditBoxSizer->Add( visibilitySizer, 0, wxEXPAND|wxTOP, 5 ); wxBoxSizer* fieldNameBoxSizer; fieldNameBoxSizer = new wxBoxSizer( wxVERTICAL ); @@ -221,15 +235,9 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( positionBoxSizer->Add( posYBoxSizer, 1, wxALL|wxEXPAND, 5 ); - fieldEditBoxSizer->Add( positionBoxSizer, 1, wxEXPAND, 5 ); + fieldEditBoxSizer->Add( positionBoxSizer, 0, wxEXPAND, 5 ); - - fieldEditBoxSizer->Add( 0, 0, 1, wxEXPAND, 5 ); - - - fieldEditBoxSizer->Add( 0, 0, 1, wxEXPAND, 5 ); - - fieldsSizer->Add( fieldEditBoxSizer, 3, wxEXPAND, 5 ); + fieldsSizer->Add( fieldEditBoxSizer, 0, wxEXPAND, 5 ); upperSizer->Add( fieldsSizer, 1, wxALL|wxEXPAND, 5 ); @@ -268,4 +276,5 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( moveUpButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::moveUpButtonHandler ), NULL, this ); stdDialogButtonSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnCancelButtonClick ), NULL, this ); stdDialogButtonSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnOKButtonClick ), NULL, this ); + } diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp index 06abf34281..a3e16b789a 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp @@ -1,10 +1,12 @@ - + ; C++ 1 + source_name + 0 ANSI connect dialog_edit_component_in_schematic_fbp @@ -16,13 +18,16 @@ . 1 + 1 0 0 + 1 1 + impl_virtual @@ -32,11 +37,15 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP - 630,520 + 715,520 wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU Component Properties + + wxFILTER_NONE + wxDefaultValidator + @@ -111,11 +120,12 @@ 5 wxALL|wxEXPAND - 1 + 0 "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" + 1 1 @@ -130,6 +140,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -163,7 +177,7 @@ 0 - wxEXPAND|wxLEFT|wxRIGHT|wxTOP + wxLEFT|wxRIGHT|wxTOP|wxEXPAND 0 @@ -172,12 +186,13 @@ none 8 - wxALL + wxALL|wxEXPAND 1 "0" "+90" "180" "-90" + 1 1 @@ -195,6 +210,10 @@ wxRA_SPECIFY_COLS Select if the component is to be rotated when drawn + + wxFILTER_NONE + wxDefaultValidator + @@ -228,7 +247,7 @@ 0 - wxEXPAND|wxLEFT|wxRIGHT|wxTOP + wxLEFT|wxRIGHT|wxTOP|wxEXPAND 0 @@ -243,6 +262,7 @@ "Normal" "Mirror ---" "Mirror |" + 1 1 @@ -260,6 +280,10 @@ wxRA_SPECIFY_COLS Pick the graphical transformation to be used when displaying the component, if any + + wxFILTER_NONE + wxDefaultValidator + @@ -310,6 +334,7 @@ + 1 1 @@ -325,6 +350,10 @@ The name of the symbol in the library from which this component came + + wxFILTER_NONE + wxDefaultValidator + @@ -368,6 +397,7 @@ 0 + 1 1 @@ -383,6 +413,10 @@ Use the alternate shape of this component. For gates, this is the "De Morgan" conversion + + wxFILTER_NONE + wxDefaultValidator + @@ -419,6 +453,7 @@ + 1 1 @@ -434,6 +469,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -470,6 +509,7 @@ + 1 0 1 @@ -486,6 +526,10 @@ Set position and style of fields and component orientation to default lib value. Fields texts are not modified. + + wxFILTER_NONE + wxDefaultValidator + @@ -531,7 +575,7 @@ 8 - wxALL|wxEXPAND + wxEXPAND|wxRIGHT|wxLEFT 5 wxID_ANY @@ -548,6 +592,7 @@ + 1 1 @@ -562,6 +607,10 @@ wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES + + wxFILTER_NONE + wxDefaultValidator + @@ -617,6 +666,7 @@ + 1 0 1 @@ -633,6 +683,10 @@ Add a new custom field + + wxFILTER_NONE + wxDefaultValidator + @@ -669,6 +723,7 @@ + 1 0 1 @@ -685,6 +740,10 @@ Delete one of the optional fields + + wxFILTER_NONE + wxDefaultValidator + @@ -721,6 +780,7 @@ + 1 0 1 @@ -737,6 +797,10 @@ Move the selected optional fields up one position + + wxFILTER_NONE + wxDefaultValidator + @@ -771,7 +835,7 @@ 5 wxEXPAND - 3 + 0 fieldEditBoxSizer @@ -781,6 +845,138 @@ 5 wxEXPAND 0 + + wxID_ANY + Options + + sbSizerOptions + wxHORIZONTAL + none + + + 5 + wxRIGHT|wxLEFT + 1 + + + "Align left" "Align center" "Align right" + + 1 + 1 + + + 0 + wxID_ANY + Horiz. Justify + 1 + + + m_FieldHJustifyCtrl + protected + + 1 + + wxRA_SPECIFY_COLS + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxRIGHT|wxLEFT + 1 + + + "Align bottom" "Align center" "Align top" + + 1 + 1 + + + 0 + wxID_ANY + Vert. Justify + 1 + + + m_FieldVJustifyCtrl + protected + + 1 + + wxRA_SPECIFY_COLS + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxTOP + 0 wxID_ANY Visibility @@ -806,6 +1002,7 @@ 0 + 1 1 @@ -821,6 +1018,10 @@ Check if you want this field visible + + wxFILTER_NONE + wxDefaultValidator + @@ -858,6 +1059,7 @@ 0 + 1 1 @@ -873,6 +1075,10 @@ Check if you want this field's text rotated 90 degrees + + wxFILTER_NONE + wxDefaultValidator + @@ -912,6 +1118,7 @@ "Normal" "Italic" "Bold" "Bold Italic" + 1 1 @@ -929,6 +1136,10 @@ wxRA_SPECIFY_COLS The style of the currently selected field's text in the schemati + + wxFILTER_NONE + wxDefaultValidator + @@ -976,6 +1187,7 @@ + 1 1 @@ -991,6 +1203,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -1027,6 +1243,7 @@ + 1 1 @@ -1042,6 +1259,10 @@ The name of the currently selected field Some fixed fields names are not editable + + wxFILTER_NONE + wxDefaultValidator + @@ -1093,6 +1314,7 @@ + 1 1 @@ -1108,6 +1330,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -1144,6 +1370,7 @@ + 1 1 @@ -1159,6 +1386,10 @@ The text (or value) of the currently selected field + + wxFILTER_NONE + wxDefaultValidator + @@ -1198,18 +1429,19 @@ 5 wxALL|wxEXPAND 0 - + textSizeBoxSizer wxVERTICAL none - + 5 0 - + + 1 1 @@ -1225,6 +1457,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -1254,13 +1490,14 @@ - + 5 wxEXPAND 0 - + + 1 1 @@ -1276,6 +1513,10 @@ The size of the currently selected field's text in the schematic + + wxFILTER_NONE + wxDefaultValidator + @@ -1314,7 +1555,7 @@ 5 wxEXPAND - 1 + 0 positionBoxSizer @@ -1336,6 +1577,7 @@ + 1 1 @@ -1351,6 +1593,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -1387,6 +1633,7 @@ + 1 1 @@ -1402,6 +1649,10 @@ The X coordinate of the text relative to the component + + wxFILTER_NONE + wxDefaultValidator + @@ -1453,6 +1704,7 @@ + 1 1 @@ -1468,6 +1720,10 @@ + + wxFILTER_NONE + wxDefaultValidator + @@ -1504,6 +1760,7 @@ + 1 1 @@ -1519,6 +1776,10 @@ The Y coordinate of the text relative to the component + + wxFILTER_NONE + wxDefaultValidator + @@ -1556,26 +1817,6 @@ - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.h b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.h index cb9044a449..e45a4a0913 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.h +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 16 2008) +// C++ code generated with wxFormBuilder (version Sep 8 2010) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -48,6 +48,8 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP : public wxDialog wxButton* addFieldButton; wxButton* deleteFieldButton; wxButton* moveUpButton; + wxRadioBox* m_FieldHJustifyCtrl; + wxRadioBox* m_FieldVJustifyCtrl; wxCheckBox* showCheckBox; wxCheckBox* rotateCheckBox; wxRadioBox* m_StyleRadioBox; @@ -61,25 +63,24 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP : public wxDialog wxTextCtrl* posXTextCtrl; wxStaticText* posYLabel; wxTextCtrl* posYTextCtrl; - - wxStdDialogButtonSizer* stdDialogButtonSizer; wxButton* stdDialogButtonSizerOK; wxButton* stdDialogButtonSizerCancel; // Virtual event handlers, overide them in your derived class - virtual void SetInitCmp( wxCommandEvent& event ){ event.Skip(); } - virtual void OnListItemDeselected( wxListEvent& event ){ event.Skip(); } - virtual void OnListItemSelected( wxListEvent& event ){ event.Skip(); } - virtual void addFieldButtonHandler( wxCommandEvent& event ){ event.Skip(); } - virtual void deleteFieldButtonHandler( wxCommandEvent& event ){ event.Skip(); } - virtual void moveUpButtonHandler( wxCommandEvent& event ){ event.Skip(); } - virtual void OnCancelButtonClick( wxCommandEvent& event ){ event.Skip(); } - virtual void OnOKButtonClick( wxCommandEvent& event ){ event.Skip(); } + virtual void SetInitCmp( wxCommandEvent& event ) { event.Skip(); } + virtual void OnListItemDeselected( wxListEvent& event ) { event.Skip(); } + virtual void OnListItemSelected( wxListEvent& event ) { event.Skip(); } + virtual void addFieldButtonHandler( wxCommandEvent& event ) { event.Skip(); } + virtual void deleteFieldButtonHandler( wxCommandEvent& event ) { event.Skip(); } + virtual void moveUpButtonHandler( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCancelButtonClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnOKButtonClick( wxCommandEvent& event ) { event.Skip(); } public: - DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 630,520 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU ); + + DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 715,520 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU ); ~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP(); }; diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index 37930adb07..8d55c300c0 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -92,24 +92,18 @@ void DialogLabelEditor::InitDialog() break; } - unsigned MINTEXTWIDTH = 40; // M's are big characters, a few establish a lot of width + int MINTEXTWIDTH = 40; // M's are big characters, a few establish a lot of width - if( m_CurrentText->m_Text.Length() < MINTEXTWIDTH ) + int max_len = 0; + if ( !multiLine ) { - wxString textWidth; - textWidth.Append( 'M', MINTEXTWIDTH ); - EnsureTextCtrlWidth( m_textLabel, &textWidth ); - } - else if ( !multiLine ) - { - EnsureTextCtrlWidth( m_textLabel ); + max_len =m_CurrentText->m_Text.Length(); } else { // calculate the length of the biggest line // we cannot use the length of the entire text that has no meaning - int max_len = 0; - int curr_len = 0; + int curr_len = MINTEXTWIDTH; int imax = m_CurrentText->m_Text.Len(); for( int count = 0; count < imax; count++ ) { @@ -125,10 +119,13 @@ void DialogLabelEditor::InitDialog() max_len = curr_len; } } - wxString textWidth; - textWidth.Append( 'M', max_len ); - EnsureTextCtrlWidth( m_textLabel, &textWidth ); } + if( max_len < MINTEXTWIDTH ) + max_len = MINTEXTWIDTH; + + wxString textWidth; + textWidth.Append( 'M', MINTEXTWIDTH ); + EnsureTextCtrlWidth( m_textLabel, &textWidth ); // Set validators m_TextOrient->SetSelection( m_CurrentText->GetSchematicTextOrientation() ); diff --git a/eeschema/dialogs/dialog_edit_label_base.cpp b/eeschema/dialogs/dialog_edit_label_base.cpp index b373a075bb..87030fc16c 100644 --- a/eeschema/dialogs/dialog_edit_label_base.cpp +++ b/eeschema/dialogs/dialog_edit_label_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 16 2008) +// C++ code generated with wxFormBuilder (version Sep 8 2010) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -107,4 +107,5 @@ DialogLabelEditor_Base::~DialogLabelEditor_Base() m_textLabelMultiLine->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DialogLabelEditor_Base::OnEnterKey ), NULL, this ); m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLabelEditor_Base::OnCancelClick ), NULL, this ); m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLabelEditor_Base::OnOkClick ), NULL, this ); + } diff --git a/eeschema/dialogs/dialog_edit_label_base.fbp b/eeschema/dialogs/dialog_edit_label_base.fbp index 955c5b1b4f..b49a834eee 100644 --- a/eeschema/dialogs/dialog_edit_label_base.fbp +++ b/eeschema/dialogs/dialog_edit_label_base.fbp @@ -2,9 +2,11 @@ - + C++ 1 + source_name + 0 UTF-8 connect dialog_edit_label_base @@ -12,66 +14,73 @@ none 1 dialog_edit_label_base - + . - + 1 + 1 1 0 - - - + + + + 1 1 - - - + impl_virtual + + + 0 wxID_ANY - - + + DialogLabelEditor_Base - + 359,347 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - + Text Editor - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + bMainSizer wxVERTICAL none @@ -85,7 +94,7 @@ 1 0 3 - + m_textControlSizer wxFLEX_GROWMODE_SPECIFIED protected @@ -96,50 +105,55 @@ wxRIGHT 0 - - + + + 1 1 - - + + 0 wxID_ANY &Text: - - + + m_staticText1 protected - - - - + + + + Enter the text to be used within the schematic - - - + + wxFILTER_NONE + wxDefaultValidator + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -147,7 +161,7 @@ wxEXPAND 1 - + -1,-1 bSizeText wxVERTICAL none @@ -156,54 +170,59 @@ wxEXPAND|wxLEFT 0 - - + + + 1 1 - - + + 0 wxID_VALUESINGLE - + 0 - + m_textLabelSingleLine protected - - + + wxTE_PROCESS_ENTER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnEnterKey - - - + + + @@ -211,54 +230,59 @@ wxEXPAND|wxLEFT 1 - - + + + 1 1 - - + + 0 wxID_VALUEMULTI - + 0 -1,60 m_textLabelMultiLine protected - - + + wxTE_MULTILINE|wxTE_PROCESS_ENTER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnEnterKey - - - + + + @@ -268,50 +292,55 @@ wxALIGN_CENTER_VERTICAL|wxRIGHT 0 - - + + + 1 1 - - + + 0 wxID_ANY &Size: - - + + m_SizeTitle protected - - - - - - - - + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -319,7 +348,7 @@ wxEXPAND 1 - + bSizeCtrlSizer wxHORIZONTAL none @@ -328,54 +357,59 @@ wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxRIGHT 0 - - + + + 1 1 - - + + 0 wxID_SIZE - + 0 - + m_TextSize protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -383,50 +417,55 @@ wxALIGN_CENTER_VERTICAL|wxLEFT 0 - - + + + 1 1 - - + + 0 wxID_ANY units - - + + m_staticSizeUnits protected - - - - - - - - + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -438,7 +477,7 @@ wxEXPAND|wxLEFT|wxRIGHT|wxTOP 0 - + m_OptionsSizer wxHORIZONTAL none @@ -447,53 +486,58 @@ wxRIGHT|wxTOP 1 - + "Right" "Up" "Left" "Down" - + + 1 1 - - + + 0 wxID_ANY O&rientation 1 - - + + m_TextOrient protected - + 0 - + wxRA_SPECIFY_COLS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -501,53 +545,58 @@ wxLEFT|wxRIGHT|wxTOP 1 - + "Normal" "Italic" "Bold" "Bold Italic" - + + 1 1 - - + + 0 wxID_ANY St&yle 1 - - + + m_TextStyle protected - + 0 - + wxRA_SPECIFY_COLS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -555,53 +604,58 @@ wxALL|wxLEFT|wxTOP 1 - + "Input" "Output" "Bidirectional" "Tri-State" "Passive" - + + 1 1 - - + + 0 wxID_ANY S&hape 1 - - + + m_TextShape protected - + 0 - + wxRA_SPECIFY_COLS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -619,17 +673,17 @@ 1 0 0 - + m_sdbSizer1 protected - + OnCancelClick - - - + + + OnOkClick - - + + diff --git a/eeschema/dialogs/dialog_edit_label_base.h b/eeschema/dialogs/dialog_edit_label_base.h index 914fb24d35..e8a567db84 100644 --- a/eeschema/dialogs/dialog_edit_label_base.h +++ b/eeschema/dialogs/dialog_edit_label_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 16 2008) +// C++ code generated with wxFormBuilder (version Sep 8 2010) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -54,12 +54,13 @@ class DialogLabelEditor_Base : public wxDialog wxButton* m_sdbSizer1Cancel; // Virtual event handlers, overide them in your derived class - virtual void OnEnterKey( wxCommandEvent& event ){ event.Skip(); } - virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); } - virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); } + virtual void OnEnterKey( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } public: + DialogLabelEditor_Base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Text Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 359,347 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DialogLabelEditor_Base(); diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp index 1124361e6e..2a9fb39a4b 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp @@ -611,7 +611,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel() m_StyleRadioBox->SetSelection( style ); - // Copy the text justification + // Select the right text justification if( field.m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) m_FieldHJustifyCtrl->SetSelection(0); else if( field.m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.cpp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.cpp index 06d81036d2..ce09239149 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.cpp +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.cpp @@ -1,219 +1,208 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 16 2008) -// http://www.wxformbuilder.org/ -// -// PLEASE DO "NOT" EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#include "dialog_edit_libentry_fields_in_lib_base.h" - -/////////////////////////////////////////////////////////////////////////// - -DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_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 ); - - wxBoxSizer* mainSizer; - mainSizer = new wxBoxSizer( wxVERTICAL ); - - wxStaticBoxSizer* fieldsSizer; - fieldsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Fields") ), wxHORIZONTAL ); - - wxStaticBoxSizer* gridStaticBoxSizer; - gridStaticBoxSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxEmptyString ), wxVERTICAL ); - - fieldListCtrl = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES ); - fieldListCtrl->SetMinSize( wxSize( 220,-1 ) ); - - gridStaticBoxSizer->Add( fieldListCtrl, 1, wxALL|wxEXPAND, 8 ); - - addFieldButton = new wxButton( this, wxID_ANY, _("Add Field"), wxDefaultPosition, wxDefaultSize, 0 ); - addFieldButton->SetToolTip( _("Add a new custom field") ); - - gridStaticBoxSizer->Add( addFieldButton, 0, wxALL|wxEXPAND, 5 ); - - deleteFieldButton = new wxButton( this, wxID_ANY, _("Delete Field"), wxDefaultPosition, wxDefaultSize, 0 ); - deleteFieldButton->SetToolTip( _("Delete one of the optional fields") ); - - gridStaticBoxSizer->Add( deleteFieldButton, 0, wxALL|wxEXPAND, 5 ); - - moveUpButton = new wxButton( this, wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 ); - moveUpButton->SetToolTip( _("Move the selected optional fields up one position") ); - - gridStaticBoxSizer->Add( moveUpButton, 0, wxALL|wxEXPAND, 5 ); - - fieldsSizer->Add( gridStaticBoxSizer, 5, wxEXPAND|wxRIGHT, 8 ); - - wxBoxSizer* fieldEditBoxSizer; - fieldEditBoxSizer = new wxBoxSizer( wxVERTICAL ); - - wxStaticBoxSizer* optionsSizer; - optionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options") ), wxHORIZONTAL ); - - wxBoxSizer* orientationSizer; - orientationSizer = new wxBoxSizer( wxHORIZONTAL ); - - wxString m_FieldHJustifyCtrlChoices[] = { _("Align left"), _("Align center"), _("Align right") }; - int m_FieldHJustifyCtrlNChoices = sizeof( m_FieldHJustifyCtrlChoices ) / sizeof( wxString ); - m_FieldHJustifyCtrl = new wxRadioBox( this, wxID_ANY, _("Horiz. Justify"), wxDefaultPosition, wxDefaultSize, m_FieldHJustifyCtrlNChoices, m_FieldHJustifyCtrlChoices, 1, wxRA_SPECIFY_COLS ); - m_FieldHJustifyCtrl->SetSelection( 1 ); - m_FieldHJustifyCtrl->SetToolTip( _("Select if the component is to be rotated when drawn") ); - - orientationSizer->Add( m_FieldHJustifyCtrl, 1, wxALL, 8 ); - - optionsSizer->Add( orientationSizer, 1, wxLEFT|wxRIGHT|wxTOP|wxEXPAND|wxALIGN_CENTER_VERTICAL, 0 ); - - wxBoxSizer* mirrorSizer; - mirrorSizer = new wxBoxSizer( wxHORIZONTAL ); - - wxString m_FieldVJustifyCtrlChoices[] = { _("Align bottom"), _("Align center"), _("Align top") }; - int m_FieldVJustifyCtrlNChoices = sizeof( m_FieldVJustifyCtrlChoices ) / sizeof( wxString ); - m_FieldVJustifyCtrl = new wxRadioBox( this, wxID_ANY, _("Vert. Justify"), wxDefaultPosition, wxDefaultSize, m_FieldVJustifyCtrlNChoices, m_FieldVJustifyCtrlChoices, 1, wxRA_SPECIFY_COLS ); - m_FieldVJustifyCtrl->SetSelection( 1 ); - m_FieldVJustifyCtrl->SetToolTip( _("Pick the graphical transformation to be used when displaying the component, if any") ); - - mirrorSizer->Add( m_FieldVJustifyCtrl, 1, wxALL, 8 ); - - optionsSizer->Add( mirrorSizer, 1, wxEXPAND|wxLEFT|wxRIGHT|wxTOP|wxALIGN_CENTER_VERTICAL, 0 ); - - fieldEditBoxSizer->Add( optionsSizer, 0, wxALIGN_TOP|wxALL|wxEXPAND, 5 ); - - wxStaticBoxSizer* visibilitySizer; - visibilitySizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Visibility") ), wxHORIZONTAL ); - - wxBoxSizer* bShowRotateSizer; - bShowRotateSizer = new wxBoxSizer( wxVERTICAL ); - - showCheckBox = new wxCheckBox( this, wxID_ANY, _("Show"), wxDefaultPosition, wxDefaultSize, 0 ); - - showCheckBox->SetToolTip( _("Check if you want this field visible") ); - - bShowRotateSizer->Add( showCheckBox, 0, wxALL, 5 ); - - rotateCheckBox = new wxCheckBox( this, wxID_ANY, _("Rotate"), wxDefaultPosition, wxDefaultSize, 0 ); - - rotateCheckBox->SetToolTip( _("Check if you want this field's text rotated 90 degrees") ); - - bShowRotateSizer->Add( rotateCheckBox, 0, wxALL, 5 ); - - visibilitySizer->Add( bShowRotateSizer, 1, wxALIGN_CENTER_VERTICAL, 5 ); - - wxString m_StyleRadioBoxChoices[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold Italic") }; - int m_StyleRadioBoxNChoices = sizeof( m_StyleRadioBoxChoices ) / sizeof( wxString ); - m_StyleRadioBox = new wxRadioBox( this, wxID_ANY, _("Style:"), wxDefaultPosition, wxDefaultSize, m_StyleRadioBoxNChoices, m_StyleRadioBoxChoices, 1, wxRA_SPECIFY_COLS ); - m_StyleRadioBox->SetSelection( 0 ); - visibilitySizer->Add( m_StyleRadioBox, 1, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - fieldEditBoxSizer->Add( visibilitySizer, 0, wxEXPAND, 5 ); - - wxBoxSizer* fieldNameBoxSizer; - fieldNameBoxSizer = new wxBoxSizer( wxVERTICAL ); - - fieldNameLabel = new wxStaticText( this, wxID_ANY, _("Field Name"), wxDefaultPosition, wxDefaultSize, 0 ); - fieldNameLabel->Wrap( -1 ); - fieldNameBoxSizer->Add( fieldNameLabel, 0, 0, 5 ); - - fieldNameTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fieldNameTextCtrl->SetToolTip( _("The text (or value) of the currently selected field") ); - - fieldNameBoxSizer->Add( fieldNameTextCtrl, 0, wxEXPAND, 5 ); - - fieldEditBoxSizer->Add( fieldNameBoxSizer, 0, wxALL|wxEXPAND, 5 ); - - wxBoxSizer* fieldTextBoxSizer; - fieldTextBoxSizer = new wxBoxSizer( wxVERTICAL ); - - fieldValueLabel = new wxStaticText( this, wxID_ANY, _("Field Value"), wxDefaultPosition, wxDefaultSize, 0 ); - fieldValueLabel->Wrap( -1 ); - fieldTextBoxSizer->Add( fieldValueLabel, 0, 0, 5 ); - - fieldValueTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fieldValueTextCtrl->SetToolTip( _("The text (or value) of the currently selected field") ); - - fieldTextBoxSizer->Add( fieldValueTextCtrl, 0, wxEXPAND, 5 ); - - fieldEditBoxSizer->Add( fieldTextBoxSizer, 0, wxALL|wxEXPAND, 5 ); - - wxBoxSizer* textSizeBoxSizer; - textSizeBoxSizer = new wxBoxSizer( wxVERTICAL ); - - textSizeLabel = new wxStaticText( this, wxID_ANY, _("Size(\")"), wxDefaultPosition, wxDefaultSize, 0 ); - textSizeLabel->Wrap( -1 ); - textSizeBoxSizer->Add( textSizeLabel, 0, 0, 5 ); - - textSizeTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - textSizeTextCtrl->SetToolTip( _("The vertical height of the currently selected field's text in the schematic") ); - - textSizeBoxSizer->Add( textSizeTextCtrl, 0, wxEXPAND, 5 ); - - fieldEditBoxSizer->Add( textSizeBoxSizer, 0, wxALL|wxEXPAND, 5 ); - - wxBoxSizer* positionBoxSizer; - positionBoxSizer = new wxBoxSizer( wxHORIZONTAL ); - - wxBoxSizer* posXBoxSizer; - posXBoxSizer = new wxBoxSizer( wxVERTICAL ); - - posXLabel = new wxStaticText( this, wxID_ANY, _("PosX(\")"), wxDefaultPosition, wxDefaultSize, 0 ); - posXLabel->Wrap( -1 ); - posXBoxSizer->Add( posXLabel, 0, 0, 5 ); - - posXTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - posXBoxSizer->Add( posXTextCtrl, 0, wxEXPAND, 5 ); - - positionBoxSizer->Add( posXBoxSizer, 1, wxALL|wxEXPAND, 5 ); - - wxBoxSizer* posYBoxSizer; - posYBoxSizer = new wxBoxSizer( wxVERTICAL ); - - posYLabel = new wxStaticText( this, wxID_ANY, _("PosY(\")"), wxDefaultPosition, wxDefaultSize, 0 ); - posYLabel->Wrap( -1 ); - posYBoxSizer->Add( posYLabel, 0, 0, 5 ); - - posYTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - posYTextCtrl->SetToolTip( _("The Y coordinate of the text relative to the component") ); - - posYBoxSizer->Add( posYTextCtrl, 0, wxEXPAND, 5 ); - - positionBoxSizer->Add( posYBoxSizer, 1, wxALL|wxEXPAND, 5 ); - - fieldEditBoxSizer->Add( positionBoxSizer, 1, wxEXPAND, 5 ); - - fieldsSizer->Add( fieldEditBoxSizer, 3, wxEXPAND, 5 ); - - mainSizer->Add( fieldsSizer, 1, wxEXPAND|wxALL, 5 ); - - stdDialogButtonSizer = new wxStdDialogButtonSizer(); - stdDialogButtonSizerOK = new wxButton( this, wxID_OK ); - stdDialogButtonSizer->AddButton( stdDialogButtonSizerOK ); - stdDialogButtonSizerCancel = new wxButton( this, wxID_CANCEL ); - stdDialogButtonSizer->AddButton( stdDialogButtonSizerCancel ); - stdDialogButtonSizer->Realize(); - mainSizer->Add( stdDialogButtonSizer, 0, wxALL|wxEXPAND, 8 ); - - this->SetSizer( mainSizer ); - this->Layout(); - - // Connect Events - this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnInitDialog ) ); - fieldListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnListItemDeselected ), NULL, this ); - fieldListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnListItemSelected ), NULL, this ); - addFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::addFieldButtonHandler ), NULL, this ); - deleteFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::deleteFieldButtonHandler ), NULL, this ); - moveUpButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::moveUpButtonHandler ), NULL, this ); - stdDialogButtonSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnCancelButtonClick ), NULL, this ); - stdDialogButtonSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnOKButtonClick ), NULL, this ); -} - -DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::~DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE() -{ - // Disconnect Events - this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnInitDialog ) ); - fieldListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnListItemDeselected ), NULL, this ); - fieldListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnListItemSelected ), NULL, this ); - addFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::addFieldButtonHandler ), NULL, this ); - deleteFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::deleteFieldButtonHandler ), NULL, this ); - moveUpButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::moveUpButtonHandler ), NULL, this ); - stdDialogButtonSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnCancelButtonClick ), NULL, this ); - stdDialogButtonSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnOKButtonClick ), NULL, this ); -} +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Sep 8 2010) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_edit_libentry_fields_in_lib_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_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 ); + + wxBoxSizer* mainSizer; + mainSizer = new wxBoxSizer( wxVERTICAL ); + + wxStaticBoxSizer* fieldsSizer; + fieldsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Fields") ), wxHORIZONTAL ); + + wxStaticBoxSizer* gridStaticBoxSizer; + gridStaticBoxSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxEmptyString ), wxVERTICAL ); + + fieldListCtrl = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES ); + fieldListCtrl->SetMinSize( wxSize( 220,-1 ) ); + + gridStaticBoxSizer->Add( fieldListCtrl, 1, wxALL|wxEXPAND, 8 ); + + addFieldButton = new wxButton( this, wxID_ANY, _("Add Field"), wxDefaultPosition, wxDefaultSize, 0 ); + addFieldButton->SetToolTip( _("Add a new custom field") ); + + gridStaticBoxSizer->Add( addFieldButton, 0, wxALL|wxEXPAND, 5 ); + + deleteFieldButton = new wxButton( this, wxID_ANY, _("Delete Field"), wxDefaultPosition, wxDefaultSize, 0 ); + deleteFieldButton->SetToolTip( _("Delete one of the optional fields") ); + + gridStaticBoxSizer->Add( deleteFieldButton, 0, wxALL|wxEXPAND, 5 ); + + moveUpButton = new wxButton( this, wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 ); + moveUpButton->SetToolTip( _("Move the selected optional fields up one position") ); + + gridStaticBoxSizer->Add( moveUpButton, 0, wxALL|wxEXPAND, 5 ); + + fieldsSizer->Add( gridStaticBoxSizer, 5, wxEXPAND|wxRIGHT, 8 ); + + wxBoxSizer* fieldEditBoxSizer; + fieldEditBoxSizer = new wxBoxSizer( wxVERTICAL ); + + wxStaticBoxSizer* optionsSizer; + optionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options") ), wxHORIZONTAL ); + + wxString m_FieldHJustifyCtrlChoices[] = { _("Align left"), _("Align center"), _("Align right") }; + int m_FieldHJustifyCtrlNChoices = sizeof( m_FieldHJustifyCtrlChoices ) / sizeof( wxString ); + m_FieldHJustifyCtrl = new wxRadioBox( this, wxID_ANY, _("Horiz. Justify"), wxDefaultPosition, wxDefaultSize, m_FieldHJustifyCtrlNChoices, m_FieldHJustifyCtrlChoices, 1, wxRA_SPECIFY_COLS ); + m_FieldHJustifyCtrl->SetSelection( 1 ); + m_FieldHJustifyCtrl->SetToolTip( _("Select if the component is to be rotated when drawn") ); + + optionsSizer->Add( m_FieldHJustifyCtrl, 1, wxBOTTOM|wxRIGHT|wxLEFT, 8 ); + + wxString m_FieldVJustifyCtrlChoices[] = { _("Align bottom"), _("Align center"), _("Align top") }; + int m_FieldVJustifyCtrlNChoices = sizeof( m_FieldVJustifyCtrlChoices ) / sizeof( wxString ); + m_FieldVJustifyCtrl = new wxRadioBox( this, wxID_ANY, _("Vert. Justify"), wxDefaultPosition, wxDefaultSize, m_FieldVJustifyCtrlNChoices, m_FieldVJustifyCtrlChoices, 1, wxRA_SPECIFY_COLS ); + m_FieldVJustifyCtrl->SetSelection( 1 ); + m_FieldVJustifyCtrl->SetToolTip( _("Pick the graphical transformation to be used when displaying the component, if any") ); + + optionsSizer->Add( m_FieldVJustifyCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 8 ); + + fieldEditBoxSizer->Add( optionsSizer, 0, wxALIGN_TOP|wxEXPAND|wxBOTTOM, 5 ); + + wxStaticBoxSizer* visibilitySizer; + visibilitySizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Visibility") ), wxHORIZONTAL ); + + wxBoxSizer* bShowRotateSizer; + bShowRotateSizer = new wxBoxSizer( wxVERTICAL ); + + showCheckBox = new wxCheckBox( this, wxID_ANY, _("Show"), wxDefaultPosition, wxDefaultSize, 0 ); + showCheckBox->SetToolTip( _("Check if you want this field visible") ); + + bShowRotateSizer->Add( showCheckBox, 0, wxALL, 5 ); + + rotateCheckBox = new wxCheckBox( this, wxID_ANY, _("Rotate"), wxDefaultPosition, wxDefaultSize, 0 ); + rotateCheckBox->SetToolTip( _("Check if you want this field's text rotated 90 degrees") ); + + bShowRotateSizer->Add( rotateCheckBox, 0, wxALL, 5 ); + + visibilitySizer->Add( bShowRotateSizer, 1, wxALIGN_CENTER_VERTICAL, 5 ); + + wxString m_StyleRadioBoxChoices[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold Italic") }; + int m_StyleRadioBoxNChoices = sizeof( m_StyleRadioBoxChoices ) / sizeof( wxString ); + m_StyleRadioBox = new wxRadioBox( this, wxID_ANY, _("Style:"), wxDefaultPosition, wxDefaultSize, m_StyleRadioBoxNChoices, m_StyleRadioBoxChoices, 1, wxRA_SPECIFY_COLS ); + m_StyleRadioBox->SetSelection( 1 ); + visibilitySizer->Add( m_StyleRadioBox, 1, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + fieldEditBoxSizer->Add( visibilitySizer, 0, wxEXPAND, 5 ); + + wxBoxSizer* fieldNameBoxSizer; + fieldNameBoxSizer = new wxBoxSizer( wxVERTICAL ); + + fieldNameLabel = new wxStaticText( this, wxID_ANY, _("Field Name"), wxDefaultPosition, wxDefaultSize, 0 ); + fieldNameLabel->Wrap( -1 ); + fieldNameBoxSizer->Add( fieldNameLabel, 0, 0, 5 ); + + fieldNameTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fieldNameTextCtrl->SetToolTip( _("The text (or value) of the currently selected field") ); + + fieldNameBoxSizer->Add( fieldNameTextCtrl, 0, wxEXPAND, 5 ); + + fieldEditBoxSizer->Add( fieldNameBoxSizer, 0, wxALL|wxEXPAND, 5 ); + + wxBoxSizer* fieldTextBoxSizer; + fieldTextBoxSizer = new wxBoxSizer( wxVERTICAL ); + + fieldValueLabel = new wxStaticText( this, wxID_ANY, _("Field Value"), wxDefaultPosition, wxDefaultSize, 0 ); + fieldValueLabel->Wrap( -1 ); + fieldTextBoxSizer->Add( fieldValueLabel, 0, 0, 5 ); + + fieldValueTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fieldValueTextCtrl->SetToolTip( _("The text (or value) of the currently selected field") ); + + fieldTextBoxSizer->Add( fieldValueTextCtrl, 0, wxEXPAND, 5 ); + + fieldEditBoxSizer->Add( fieldTextBoxSizer, 0, wxALL|wxEXPAND, 5 ); + + wxBoxSizer* textSizeBoxSizer; + textSizeBoxSizer = new wxBoxSizer( wxVERTICAL ); + + textSizeLabel = new wxStaticText( this, wxID_ANY, _("Size(\")"), wxDefaultPosition, wxDefaultSize, 0 ); + textSizeLabel->Wrap( -1 ); + textSizeBoxSizer->Add( textSizeLabel, 0, 0, 5 ); + + textSizeTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + textSizeTextCtrl->SetToolTip( _("The vertical height of the currently selected field's text in the schematic") ); + + textSizeBoxSizer->Add( textSizeTextCtrl, 0, wxEXPAND, 5 ); + + fieldEditBoxSizer->Add( textSizeBoxSizer, 0, wxALL|wxEXPAND, 5 ); + + wxBoxSizer* positionBoxSizer; + positionBoxSizer = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* posXBoxSizer; + posXBoxSizer = new wxBoxSizer( wxVERTICAL ); + + posXLabel = new wxStaticText( this, wxID_ANY, _("PosX(\")"), wxDefaultPosition, wxDefaultSize, 0 ); + posXLabel->Wrap( -1 ); + posXBoxSizer->Add( posXLabel, 0, 0, 5 ); + + posXTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + posXBoxSizer->Add( posXTextCtrl, 0, wxEXPAND, 5 ); + + positionBoxSizer->Add( posXBoxSizer, 1, wxALL|wxEXPAND, 5 ); + + wxBoxSizer* posYBoxSizer; + posYBoxSizer = new wxBoxSizer( wxVERTICAL ); + + posYLabel = new wxStaticText( this, wxID_ANY, _("PosY(\")"), wxDefaultPosition, wxDefaultSize, 0 ); + posYLabel->Wrap( -1 ); + posYBoxSizer->Add( posYLabel, 0, 0, 5 ); + + posYTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + posYTextCtrl->SetToolTip( _("The Y coordinate of the text relative to the component") ); + + posYBoxSizer->Add( posYTextCtrl, 0, wxEXPAND, 5 ); + + positionBoxSizer->Add( posYBoxSizer, 1, wxALL|wxEXPAND, 5 ); + + fieldEditBoxSizer->Add( positionBoxSizer, 1, wxEXPAND, 5 ); + + fieldsSizer->Add( fieldEditBoxSizer, 3, wxEXPAND, 5 ); + + mainSizer->Add( fieldsSizer, 1, wxEXPAND|wxALL, 5 ); + + stdDialogButtonSizer = new wxStdDialogButtonSizer(); + stdDialogButtonSizerOK = new wxButton( this, wxID_OK ); + stdDialogButtonSizer->AddButton( stdDialogButtonSizerOK ); + stdDialogButtonSizerCancel = new wxButton( this, wxID_CANCEL ); + stdDialogButtonSizer->AddButton( stdDialogButtonSizerCancel ); + stdDialogButtonSizer->Realize(); + mainSizer->Add( stdDialogButtonSizer, 0, wxALL|wxEXPAND, 8 ); + + this->SetSizer( mainSizer ); + this->Layout(); + + // Connect Events + this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnInitDialog ) ); + fieldListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnListItemDeselected ), NULL, this ); + fieldListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnListItemSelected ), NULL, this ); + addFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::addFieldButtonHandler ), NULL, this ); + deleteFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::deleteFieldButtonHandler ), NULL, this ); + moveUpButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::moveUpButtonHandler ), NULL, this ); + stdDialogButtonSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnCancelButtonClick ), NULL, this ); + stdDialogButtonSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnOKButtonClick ), NULL, this ); +} + +DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::~DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE() +{ + // Disconnect Events + this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnInitDialog ) ); + fieldListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnListItemDeselected ), NULL, this ); + fieldListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnListItemSelected ), NULL, this ); + addFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::addFieldButtonHandler ), NULL, this ); + deleteFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::deleteFieldButtonHandler ), NULL, this ); + moveUpButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::moveUpButtonHandler ), NULL, this ); + stdDialogButtonSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnCancelButtonClick ), NULL, this ); + stdDialogButtonSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::OnOKButtonClick ), NULL, this ); + +} diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.fbp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.fbp index 4db78c89d8..425df38657 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.fbp +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.fbp @@ -5,6 +5,8 @@ ; C++ 1 + source_name + 0 ANSI connect dialog_edit_libentry_fields_in_lib_base @@ -12,66 +14,73 @@ none 1 DialogEditLibentryFields_in_lib_base - + . - + 1 + 1 0 0 - - - + + + + 1 1 - - - + impl_virtual + + + 0 wxID_ANY - - + + DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE - - 773,550 + + 615,550 wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU - + Fields Properties - - - - - - - - - - - - - + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + OnInitDialog - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + mainSizer wxVERTICAL none @@ -82,90 +91,95 @@ wxID_ANY Fields - + fieldsSizer wxHORIZONTAL none - + 8 wxEXPAND|wxRIGHT 5 wxID_ANY - - + + gridStaticBoxSizer wxVERTICAL none - + 8 wxALL|wxEXPAND 1 - - + + + 1 1 - - + + 0 wxID_ANY - + 220,-1 fieldListCtrl protected - - + + wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnListItemDeselected - - - + + + OnListItemSelected - - - - - - - - - - - - - - + + + + + + + + + + + + + + @@ -173,51 +187,56 @@ wxALL|wxEXPAND 0 - - + + + 1 0 1 - - + + 0 wxID_ANY Add Field - - + + addFieldButton protected - - - - + + + + Add a new custom field - - - + + wxFILTER_NONE + wxDefaultValidator + + + + addFieldButtonHandler - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -225,51 +244,56 @@ wxALL|wxEXPAND 0 - - + + + 1 0 1 - - + + 0 wxID_ANY Delete Field - - + + deleteFieldButton protected - - - - + + + + Delete one of the optional fields - - - + + wxFILTER_NONE + wxDefaultValidator + + + + deleteFieldButtonHandler - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -277,51 +301,56 @@ wxALL|wxEXPAND 0 - - + + + 1 0 1 - - + + 0 wxID_ANY Move Up - - + + moveUpButton protected - - - - + + + + Move the selected optional fields up one position - - - + + wxFILTER_NONE + wxDefaultValidator + + + + moveUpButtonHandler - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -331,150 +360,138 @@ wxEXPAND 3 - + fieldEditBoxSizer wxVERTICAL none 5 - wxALIGN_TOP|wxALL|wxEXPAND + wxALIGN_TOP|wxEXPAND|wxBOTTOM 0 wxID_ANY Options - + optionsSizer wxHORIZONTAL none - + - 0 - wxLEFT|wxRIGHT|wxTOP|wxEXPAND|wxALIGN_CENTER_VERTICAL + 8 + wxBOTTOM|wxRIGHT|wxLEFT 1 - - - orientationSizer - wxHORIZONTAL - none - - 8 - wxALL - 1 - - - "Align left" "Align center" "Align right" - - 1 - - - 0 - wxID_ANY - Horiz. Justify - 1 - - - m_FieldHJustifyCtrl - protected - - 1 - - wxRA_SPECIFY_COLS - - Select if the component is to be rotated when drawn - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + "Align left" "Align center" "Align right" + + 1 + 1 + + + 0 + wxID_ANY + Horiz. Justify + 1 + + + m_FieldHJustifyCtrl + protected + + 1 + + wxRA_SPECIFY_COLS + + Select if the component is to be rotated when drawn + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + - 0 - wxEXPAND|wxLEFT|wxRIGHT|wxTOP|wxALIGN_CENTER_VERTICAL - 1 - - - mirrorSizer - wxHORIZONTAL - none - - 8 - wxALL - 1 - - - "Align bottom" "Align center" "Align top" - - 1 - - - 0 - wxID_ANY - Vert. Justify - 1 - - - m_FieldVJustifyCtrl - protected - - 1 - - wxRA_SPECIFY_COLS - - Pick the graphical transformation to be used when displaying the component, if any - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 8 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + "Align bottom" "Align center" "Align top" + + 1 + 1 + + + 0 + wxID_ANY + Vert. Justify + 1 + + + m_FieldVJustifyCtrl + protected + + 1 + + wxRA_SPECIFY_COLS + + Pick the graphical transformation to be used when displaying the component, if any + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -486,17 +503,17 @@ wxID_ANY Visibility - + visibilitySizer wxHORIZONTAL none - + 5 wxALIGN_CENTER_VERTICAL 1 - + bShowRotateSizer wxVERTICAL none @@ -505,51 +522,56 @@ wxALL 0 - + 0 - + + 1 1 - - + + 0 wxID_ANY Show - - + + showCheckBox protected - - - - + + + + Check if you want this field visible - - - - - - - - - - - - - - - - - - - - - - - - - - - + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -557,51 +579,56 @@ wxALL 0 - + 0 - + + 1 1 - - + + 0 wxID_ANY Rotate - - + + rotateCheckBox protected - - - - + + + + Check if you want this field's text rotated 90 degrees - - - - - - - - - - - - - - - - - - - - - - - - - - - + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -611,53 +638,58 @@ wxBOTTOM|wxRIGHT|wxLEFT 1 - + "Normal" "Italic" "Bold" "Bold Italic" - + + 1 1 - - + + 0 wxID_ANY Style: 1 - - + + m_StyleRadioBox protected - - 0 - + + 1 + wxRA_SPECIFY_COLS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -667,59 +699,64 @@ wxALL|wxEXPAND 0 - + fieldNameBoxSizer wxVERTICAL none 5 - + 0 - - + + + 1 1 - - + + 0 wxID_ANY Field Name - - + + fieldNameLabel protected - - - - - - - - + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -727,54 +764,59 @@ wxEXPAND 0 - - + + + 1 1 - - + + 0 wxID_ANY - + 0 - + fieldNameTextCtrl protected - - - - + + + + The text (or value) of the currently selected field - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -784,59 +826,64 @@ wxALL|wxEXPAND 0 - + fieldTextBoxSizer wxVERTICAL none 5 - + 0 - - + + + 1 1 - - + + 0 wxID_ANY Field Value - - + + fieldValueLabel protected - - - - - - - - + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -844,54 +891,59 @@ wxEXPAND 0 - - + + + 1 1 - - + + 0 wxID_ANY - + 0 - + fieldValueTextCtrl protected - - - - + + + + The text (or value) of the currently selected field - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -901,59 +953,64 @@ wxALL|wxEXPAND 0 - + textSizeBoxSizer wxVERTICAL none 5 - + 0 - - + + + 1 1 - - + + 0 wxID_ANY Size(") - - + + textSizeLabel protected - - - - - - - - + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -961,54 +1018,59 @@ wxEXPAND 0 - - + + + 1 1 - - + + 0 wxID_ANY - + 0 - + textSizeTextCtrl protected - - - - + + + + The vertical height of the currently selected field's text in the schematic - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1018,7 +1080,7 @@ wxEXPAND 1 - + positionBoxSizer wxHORIZONTAL none @@ -1027,59 +1089,64 @@ wxALL|wxEXPAND 1 - + posXBoxSizer wxVERTICAL none 5 - + 0 - - + + + 1 1 - - + + 0 wxID_ANY PosX(") - - + + posXLabel protected - - - - - - - - + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -1087,54 +1154,59 @@ wxEXPAND 0 - - + + + 1 1 - - + + 0 wxID_ANY - + 0 - + posXTextCtrl protected - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1144,59 +1216,64 @@ wxALL|wxEXPAND 1 - + posYBoxSizer wxVERTICAL none 5 - + 0 - - + + + 1 1 - - + + 0 wxID_ANY PosY(") - - + + posYLabel protected - - - - - - - - + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -1204,54 +1281,59 @@ wxEXPAND 0 - - + + + 1 1 - - + + 0 wxID_ANY - + 0 - + posYTextCtrl protected - - - - + + + + The Y coordinate of the text relative to the component - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1275,17 +1357,17 @@ 1 0 0 - + stdDialogButtonSizer protected - + OnCancelButtonClick - - - + + + OnOKButtonClick - - + + diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.h b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.h index cf43cb0141..01e99af72b 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.h +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib_base.h @@ -1,79 +1,80 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 16 2008) -// http://www.wxformbuilder.org/ -// -// PLEASE DO "NOT" EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#ifndef __dialog_edit_libentry_fields_in_lib_base__ -#define __dialog_edit_libentry_fields_in_lib_base__ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE -/////////////////////////////////////////////////////////////////////////////// -class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE : public wxDialog -{ - private: - - protected: - wxListCtrl* fieldListCtrl; - wxButton* addFieldButton; - wxButton* deleteFieldButton; - wxButton* moveUpButton; - wxRadioBox* m_FieldHJustifyCtrl; - wxRadioBox* m_FieldVJustifyCtrl; - wxCheckBox* showCheckBox; - wxCheckBox* rotateCheckBox; - wxRadioBox* m_StyleRadioBox; - wxStaticText* fieldNameLabel; - wxTextCtrl* fieldNameTextCtrl; - wxStaticText* fieldValueLabel; - wxTextCtrl* fieldValueTextCtrl; - wxStaticText* textSizeLabel; - wxTextCtrl* textSizeTextCtrl; - wxStaticText* posXLabel; - wxTextCtrl* posXTextCtrl; - wxStaticText* posYLabel; - wxTextCtrl* posYTextCtrl; - wxStdDialogButtonSizer* stdDialogButtonSizer; - wxButton* stdDialogButtonSizerOK; - wxButton* stdDialogButtonSizerCancel; - - // Virtual event handlers, overide them in your derived class - virtual void OnInitDialog( wxInitDialogEvent& event ){ event.Skip(); } - virtual void OnListItemDeselected( wxListEvent& event ){ event.Skip(); } - virtual void OnListItemSelected( wxListEvent& event ){ event.Skip(); } - virtual void addFieldButtonHandler( wxCommandEvent& event ){ event.Skip(); } - virtual void deleteFieldButtonHandler( wxCommandEvent& event ){ event.Skip(); } - virtual void moveUpButtonHandler( wxCommandEvent& event ){ event.Skip(); } - virtual void OnCancelButtonClick( wxCommandEvent& event ){ event.Skip(); } - virtual void OnOKButtonClick( wxCommandEvent& event ){ event.Skip(); } - - - public: - DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Fields Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 773,550 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU ); - ~DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE(); - -}; - -#endif //__dialog_edit_libentry_fields_in_lib_base__ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Sep 8 2010) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __dialog_edit_libentry_fields_in_lib_base__ +#define __dialog_edit_libentry_fields_in_lib_base__ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE : public wxDialog +{ + private: + + protected: + wxListCtrl* fieldListCtrl; + wxButton* addFieldButton; + wxButton* deleteFieldButton; + wxButton* moveUpButton; + wxRadioBox* m_FieldHJustifyCtrl; + wxRadioBox* m_FieldVJustifyCtrl; + wxCheckBox* showCheckBox; + wxCheckBox* rotateCheckBox; + wxRadioBox* m_StyleRadioBox; + wxStaticText* fieldNameLabel; + wxTextCtrl* fieldNameTextCtrl; + wxStaticText* fieldValueLabel; + wxTextCtrl* fieldValueTextCtrl; + wxStaticText* textSizeLabel; + wxTextCtrl* textSizeTextCtrl; + wxStaticText* posXLabel; + wxTextCtrl* posXTextCtrl; + wxStaticText* posYLabel; + wxTextCtrl* posYTextCtrl; + wxStdDialogButtonSizer* stdDialogButtonSizer; + wxButton* stdDialogButtonSizerOK; + wxButton* stdDialogButtonSizerCancel; + + // Virtual event handlers, overide them in your derived class + virtual void OnInitDialog( wxInitDialogEvent& event ) { event.Skip(); } + virtual void OnListItemDeselected( wxListEvent& event ) { event.Skip(); } + virtual void OnListItemSelected( wxListEvent& event ) { event.Skip(); } + virtual void addFieldButtonHandler( wxCommandEvent& event ) { event.Skip(); } + virtual void deleteFieldButtonHandler( wxCommandEvent& event ) { event.Skip(); } + virtual void moveUpButtonHandler( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCancelButtonClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnOKButtonClick( wxCommandEvent& event ) { event.Skip(); } + + + public: + + DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Fields Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 615,550 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU ); + ~DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE(); + +}; + +#endif //__dialog_edit_libentry_fields_in_lib_base__ diff --git a/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.cpp b/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.cpp index b2eed498a9..8971192425 100644 --- a/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.cpp +++ b/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.cpp @@ -11,7 +11,7 @@ DIALOG_SCH_EDIT_SHEET_PIN_BASE::DIALOG_SCH_EDIT_SHEET_PIN_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 ); + this->SetSizeHints( wxSize( 350,-1 ), wxDefaultSize ); wxBoxSizer* m_mainSizer; m_mainSizer = new wxBoxSizer( wxVERTICAL ); @@ -21,6 +21,7 @@ DIALOG_SCH_EDIT_SHEET_PIN_BASE::DIALOG_SCH_EDIT_SHEET_PIN_BASE( wxWindow* parent wxFlexGridSizer* fgSizer1; fgSizer1 = new wxFlexGridSizer( 4, 3, 0, 0 ); + fgSizer1->AddGrowableCol( 1 ); fgSizer1->SetFlexibleDirection( wxBOTH ); fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); @@ -85,7 +86,6 @@ DIALOG_SCH_EDIT_SHEET_PIN_BASE::DIALOG_SCH_EDIT_SHEET_PIN_BASE( wxWindow* parent this->SetSizer( m_mainSizer ); this->Layout(); - m_mainSizer->Fit( this ); this->Centre( wxBOTH ); } diff --git a/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.fbp b/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.fbp index 8d7ecb7fc9..1c16d3ba54 100644 --- a/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.fbp +++ b/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.fbp @@ -34,10 +34,10 @@ 0 wxID_ANY - + 350,-1 DIALOG_SCH_EDIT_SHEET_PIN_BASE - + 350,189 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER Sheet Pin Properties @@ -100,7 +100,7 @@ 3 wxBOTH - + 1 0 diff --git a/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.h b/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.h index 42cb65e77b..743a952c59 100644 --- a/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.h +++ b/eeschema/dialogs/dialog_sch_edit_sheet_pin_base.h @@ -52,7 +52,7 @@ class DIALOG_SCH_EDIT_SHEET_PIN_BASE : public wxDialog public: - DIALOG_SCH_EDIT_SHEET_PIN_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Sheet Pin Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_SCH_EDIT_SHEET_PIN_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Sheet Pin Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 350,189 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_SCH_EDIT_SHEET_PIN_BASE(); }; diff --git a/eeschema/edit_component_in_schematic.cpp b/eeschema/edit_component_in_schematic.cpp index ce923f9ca7..e4f831d7a7 100644 --- a/eeschema/edit_component_in_schematic.cpp +++ b/eeschema/edit_component_in_schematic.cpp @@ -42,7 +42,7 @@ void SCH_EDIT_FRAME::StartMoveCmpField( SCH_FIELD* aField, wxDC* DC ) SCH_COMPONENT* comp = (SCH_COMPONENT*) aField->GetParent(); SAFE_DELETE( g_ItemToUndoCopy ); - g_ItemToUndoCopy = comp->GenCopy(); + g_ItemToUndoCopy = new SCH_COMPONENT( *comp ); pos = comp->m_Pos; diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index 5d288078ef..3008101bf5 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -41,7 +41,7 @@ void SCH_EDIT_FRAME::StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC ) if( (TextStruct->m_Flags & IS_NEW) == 0 ) { delete g_ItemToUndoCopy; - g_ItemToUndoCopy = TextStruct->GenCopy(); + g_ItemToUndoCopy = TextStruct->Clone(); } TextStruct->m_Flags |= IS_MOVED; diff --git a/eeschema/eeredraw.cpp b/eeschema/eeredraw.cpp index 981beb246b..517a79c04a 100644 --- a/eeschema/eeredraw.cpp +++ b/eeschema/eeredraw.cpp @@ -14,10 +14,14 @@ #include "general.h" #include "protos.h" #include "class_library.h" -#include "sch_sheet.h" -#include "sch_sheet_path.h" +#include "sch_bus_entry.h" #include "sch_component.h" #include "sch_items.h" +#include "sch_line.h" +#include "sch_no_connect.h" +#include "sch_polyline.h" +#include "sch_sheet.h" +#include "sch_sheet_path.h" #include "build_version.h" @@ -185,8 +189,8 @@ void DrawStructsInGhost( WinEDA_DrawPanel* aPanel, case SCH_POLYLINE_T: { SCH_POLYLINE* Struct = (SCH_POLYLINE*) aItem; - GRMoveTo( Struct->m_PolyPoints[0].x + aOffset.x, - Struct->m_PolyPoints[0].y + aOffset.y ); + GRMoveTo( Struct->m_PolyPoints[0].x + aOffset.x, Struct->m_PolyPoints[0].y + aOffset.y ); + for( unsigned ii = 1; ii < Struct->GetCornerCount(); ii++ ) GRLineTo( &aPanel->m_ClipBox, aDC, @@ -202,15 +206,16 @@ void DrawStructsInGhost( WinEDA_DrawPanel* aPanel, { SCH_LINE* Struct; Struct = (SCH_LINE*) aItem; + if( (Struct->m_Flags & STARTPOINT) == 0 ) { - GRMoveTo( Struct->m_Start.x + aOffset.x, - Struct->m_Start.y + aOffset.y ); + GRMoveTo( Struct->m_Start.x + aOffset.x, Struct->m_Start.y + aOffset.y ); } else { GRMoveTo( Struct->m_Start.x, Struct->m_Start.y ); } + if( (Struct->m_Flags & ENDPOINT) == 0 ) { GRLineTo( &aPanel->m_ClipBox, aDC, Struct->m_End.x + aOffset.x, diff --git a/eeschema/events_called_functions_for_edit.cpp b/eeschema/events_called_functions_for_edit.cpp index a54ce18405..fca844941f 100644 --- a/eeschema/events_called_functions_for_edit.cpp +++ b/eeschema/events_called_functions_for_edit.cpp @@ -34,7 +34,7 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event ) case SCH_COMPONENT_T: { SCH_COMPONENT* newitem; - newitem = ((SCH_COMPONENT*) curr_item)->GenCopy(); + newitem = new SCH_COMPONENT( *( (SCH_COMPONENT*) curr_item ) ); newitem->m_TimeStamp = GetTimeStamp(); newitem->ClearAnnotation( NULL ); newitem->m_Flags = IS_NEW; @@ -51,7 +51,7 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event ) case SCH_GLOBAL_LABEL_T: case SCH_HIERARCHICAL_LABEL_T: { - SCH_TEXT* newitem = ((SCH_TEXT*) curr_item)->GenCopy(); + SCH_TEXT* newitem = (SCH_TEXT*) curr_item->Clone(); newitem->m_Flags = IS_NEW; StartMoveTexte( newitem, &dc ); /* Redraw the original part in XOR mode */ diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index 4e8fd0af99..a8f08621cd 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -420,7 +420,8 @@ void SCH_EDIT_FRAME::StartMovePart( SCH_COMPONENT* Component, wxDC* DC ) { SAFE_DELETE( g_ItemToUndoCopy ); } - g_ItemToUndoCopy = Component->GenCopy(); + + g_ItemToUndoCopy = Component->Clone(); } DrawPanel->CursorOff( DC ); diff --git a/eeschema/hotkeys.cpp b/eeschema/hotkeys.cpp index 1cde24b81f..f9da0d5a00 100644 --- a/eeschema/hotkeys.cpp +++ b/eeschema/hotkeys.cpp @@ -13,6 +13,7 @@ #include "libeditframe.h" #include "class_libentry.h" #include "sch_items.h" +#include "sch_line.h" #include "sch_component.h" #include "sch_sheet.h" @@ -510,8 +511,10 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) if( DrawStruct->Type() == SCH_LINE_T ) { SCH_LINE* segment = (SCH_LINE*) DrawStruct; + if( segment->GetLayer() != LAYER_BUS ) break; + // Bus in progress: OnLeftClick( DC, MousePos ); } @@ -670,8 +673,13 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) if( DrawStruct == NULL ) { - // Find the schematic object to move under the cursor - DrawStruct = SchematicGeneralLocateAndDisplay( false ); + // For a drag or copy command, try to find first a component: + if( DrawStruct == NULL && HK_Descr->m_Idcommand != HK_MOVE_COMPONENT_OR_ITEM ) + DrawStruct = LocateSmallestComponent( GetScreen() ); + + // If no component, find the schematic object to move/drag or copy under the cursor + if( DrawStruct == NULL ) + DrawStruct = SchematicGeneralLocateAndDisplay( false ); if( DrawStruct == NULL ) break; @@ -748,7 +756,12 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) case SCH_LINE_T: if( ( (SCH_ITEM*) DrawStruct )->GetLayer() == LAYER_WIRE ) - wxPostEvent( this, eventDragWire ); + { + if( HK_Descr->m_Idcommand == HK_DRAG ) + wxPostEvent( this, eventDragWire ); + else + wxPostEvent( this, eventMoveItem ); + } break; default: diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index b4a66332a6..4d4063c32c 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -263,8 +263,8 @@ void LIB_ARC::DoOffset( const wxPoint& aOffset ) bool LIB_ARC::DoTestInside( EDA_Rect& aRect ) const { - return aRect.Inside( m_ArcStart.x, -m_ArcStart.y ) - || aRect.Inside( m_ArcEnd.x, -m_ArcEnd.y ); + return aRect.Contains( m_ArcStart.x, -m_ArcStart.y ) + || aRect.Contains( m_ArcEnd.x, -m_ArcEnd.y ); } diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp index ac21363750..fa75cc2477 100644 --- a/eeschema/lib_bezier.cpp +++ b/eeschema/lib_bezier.cpp @@ -164,7 +164,7 @@ bool LIB_BEZIER::DoTestInside( EDA_Rect& aRect ) const { for( size_t i = 0; i < m_PolyPoints.size(); i++ ) { - if( aRect.Inside( m_PolyPoints[i].x, -m_PolyPoints[i].y ) ) + if( aRect.Contains( m_PolyPoints[i].x, -m_PolyPoints[i].y ) ) return true; } diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index e46cca4dd7..2c19f58706 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -152,7 +152,7 @@ bool LIB_CIRCLE::DoTestInside( EDA_Rect& aRect ) const * FIXME: This fails to take into account the radius around the center * point. */ - return aRect.Inside( m_Pos.x, -m_Pos.y ); + return aRect.Contains( m_Pos.x, -m_Pos.y ); } diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 2e9cbfb133..8d402feb74 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -326,8 +326,6 @@ void LIB_FIELD::drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& if( aData ) text = *(wxString*)aData; - else if( InEditMode() ) - text = GetFullText( m_Unit ); else text = m_Text; @@ -350,6 +348,11 @@ void LIB_FIELD::drawGraphic( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& bool LIB_FIELD::HitTest( const wxPoint& aPosition ) { + // Because HitTest is mainly used to select the field + // return always false if this field is void + if( IsVoid() ) + return false; + return HitTest( aPosition, 0, DefaultTransform ); } @@ -466,7 +469,7 @@ bool LIB_FIELD::DoTestInside( EDA_Rect& rect ) const * FIXME: This fails to take into acount the size and/or orientation of * the text. */ - return rect.Inside( m_Pos.x, -m_Pos.y ); + return rect.Contains( m_Pos.x, -m_Pos.y ); } diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index fe6876b9f1..bc537a6e8d 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -106,6 +106,15 @@ public: void SetFields( const std::vector aFields ); + /** + * Function IsVoid + * @return true if the field value is void (no text in this field) + */ + bool IsVoid() + { + return m_Text.IsEmpty(); + } + /** * Function IsVisible * @return true is this field is visible, false if flagged invisible diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 9f75e725dc..1c540d3671 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -1653,7 +1653,7 @@ bool LIB_PIN::DoTestInside( EDA_Rect& rect ) const { wxPoint end = ReturnPinEndPoint(); - return rect.Inside( m_position.x, -m_position.y ) || rect.Inside( end.x, -end.y ); + return rect.Contains( m_position.x, -m_position.y ) || rect.Contains( end.x, -end.y ); } diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp index 7f77ed58b5..b41b910a5b 100644 --- a/eeschema/lib_polyline.cpp +++ b/eeschema/lib_polyline.cpp @@ -162,7 +162,7 @@ bool LIB_POLYLINE::DoTestInside( EDA_Rect& aRect ) const { for( size_t i = 0; i < m_PolyPoints.size(); i++ ) { - if( aRect.Inside( m_PolyPoints[i].x, -m_PolyPoints[i].y ) ) + if( aRect.Contains( m_PolyPoints[i].x, -m_PolyPoints[i].y ) ) return true; } diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp index 25ee4a17e5..3b7c00def3 100644 --- a/eeschema/lib_rectangle.cpp +++ b/eeschema/lib_rectangle.cpp @@ -119,7 +119,7 @@ void LIB_RECTANGLE::DoOffset( const wxPoint& aOffset ) bool LIB_RECTANGLE::DoTestInside( EDA_Rect& aRect ) const { - return aRect.Inside( m_Pos.x, -m_Pos.y ) || aRect.Inside( m_End.x, -m_End.y ); + return aRect.Contains( m_Pos.x, -m_Pos.y ) || aRect.Contains( m_End.x, -m_End.y ); } diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index d9d1312e42..07d78862b9 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -223,7 +223,7 @@ bool LIB_TEXT::DoTestInside( EDA_Rect& rect ) const * FIXME: This should calculate the text size and justification and * use rectangle instect. */ - return rect.Inside( m_Pos.x, -m_Pos.y ); + return rect.Contains( m_Pos.x, -m_Pos.y ); } diff --git a/eeschema/load_one_schematic_file.cpp b/eeschema/load_one_schematic_file.cpp index 16a94e0db8..4885d21592 100644 --- a/eeschema/load_one_schematic_file.cpp +++ b/eeschema/load_one_schematic_file.cpp @@ -11,9 +11,13 @@ #include "general.h" #include "protos.h" +#include "sch_bus_entry.h" #include "sch_marker.h" #include "sch_items.h" +#include "sch_line.h" +#include "sch_no_connect.h" #include "sch_component.h" +#include "sch_polyline.h" #include "sch_text.h" #include "sch_sheet.h" diff --git a/eeschema/locate.cpp b/eeschema/locate.cpp index bb6e835688..f6101b8d7c 100644 --- a/eeschema/locate.cpp +++ b/eeschema/locate.cpp @@ -11,9 +11,13 @@ #include "general.h" #include "protos.h" #include "class_library.h" +#include "sch_bus_entry.h" #include "sch_marker.h" #include "sch_items.h" #include "sch_component.h" +#include "sch_line.h" +#include "sch_no_connect.h" +#include "sch_polyline.h" #include "sch_sheet.h" #include "lib_pin.h" #include "template_fieldnames.h" @@ -139,6 +143,7 @@ int PickItemsInBlock( BLOCK_SELECTOR& aBlock, SCH_SCREEN* aScreen ) for( ; item != NULL; item = item->Next() ) { + // an item is picked if its bounding box intersects the reference area if( item->HitTest( area ) ) { /* Put this structure in the picked list: */ @@ -310,7 +315,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList ) EDA_Rect BoundaryBox = field->GetBoundingBox(); - if( BoundaryBox.Inside( aPosRef ) ) + if( BoundaryBox.Contains( aPosRef ) ) { LastSnappedStruct = field; return true; @@ -323,7 +328,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList ) #define STRUCT ( (SCH_COMPONENT*) DrawList ) EDA_Rect BoundaryBox = STRUCT->GetBoundingBox(); - if( BoundaryBox.Inside( aPosRef ) ) + if( BoundaryBox.Contains( aPosRef ) ) { LastSnappedStruct = DrawList; return true; diff --git a/eeschema/netlist.cpp b/eeschema/netlist.cpp index 2c2baba89a..9e967c6cec 100644 --- a/eeschema/netlist.cpp +++ b/eeschema/netlist.cpp @@ -14,6 +14,8 @@ #include "lib_pin.h" #include "sch_items.h" #include "sch_component.h" +#include "sch_line.h" +#include "sch_no_connect.h" #include "sch_text.h" #include "sch_sheet.h" diff --git a/eeschema/onleftclick.cpp b/eeschema/onleftclick.cpp index 828df81c2f..a2c73ad69f 100644 --- a/eeschema/onleftclick.cpp +++ b/eeschema/onleftclick.cpp @@ -12,9 +12,12 @@ #include "general.h" #include "protos.h" +#include "sch_bus_entry.h" #include "sch_text.h" #include "sch_marker.h" #include "sch_items.h" +#include "sch_line.h" +#include "sch_no_connect.h" #include "sch_component.h" #include "sch_sheet.h" diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index fad59edc67..4f6ca9e4e3 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -15,10 +15,13 @@ #include "protos.h" #include "hotkeys.h" #include "class_library.h" +#include "sch_bus_entry.h" #include "sch_marker.h" #include "sch_text.h" #include "sch_items.h" #include "sch_component.h" +#include "sch_line.h" +#include "sch_no_connect.h" #include "sch_sheet.h" #include "sch_sheet_path.h" diff --git a/eeschema/operations_on_items_lists.cpp b/eeschema/operations_on_items_lists.cpp index ea006c6183..5a1687e88c 100644 --- a/eeschema/operations_on_items_lists.cpp +++ b/eeschema/operations_on_items_lists.cpp @@ -13,7 +13,11 @@ #include "general.h" #include "protos.h" +#include "sch_bus_entry.h" #include "sch_marker.h" +#include "sch_line.h" +#include "sch_no_connect.h" +#include "sch_polyline.h" #include "sch_sheet.h" #include "sch_component.h" #include "sch_items.h" @@ -30,8 +34,7 @@ void RotateListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& rotationPoint ) } -void DeleteItemsInList( WinEDA_DrawPanel* panel, - PICKED_ITEMS_LIST& aItemsList ); +void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList ); void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveVector ); @@ -95,8 +98,7 @@ void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList ) if( item->Type() == SCH_SHEET_LABEL_T ) { /* this item is depending on a sheet, and is not in global list */ - wxMessageBox( wxT("DeleteItemsInList() err: unexpected \ -SCH_SHEET_LABEL_T" ) ); + wxMessageBox( wxT( "DeleteItemsInList() err: unexpected SCH_SHEET_LABEL_T" ) ); } else { @@ -218,82 +220,15 @@ void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList, */ SCH_ITEM* DuplicateStruct( SCH_ITEM* aDrawStruct, bool aClone ) { - SCH_ITEM* NewDrawStruct = NULL; + wxCHECK_MSG( aDrawStruct != NULL, NULL, + wxT( "Cannot duplicate NULL schematic item! Bad programmer." ) ); - if( aDrawStruct == NULL ) - { - wxMessageBox( wxT( "DuplicateStruct error: NULL struct" ) ); - return NULL; - } - - switch( aDrawStruct->Type() ) - { - case SCH_POLYLINE_T: - NewDrawStruct = ( (SCH_POLYLINE*) aDrawStruct )->GenCopy(); - break; - - case SCH_LINE_T: - NewDrawStruct = ( (SCH_LINE*) aDrawStruct )->GenCopy(); - break; - - case SCH_BUS_ENTRY_T: - NewDrawStruct = ( (SCH_BUS_ENTRY*) aDrawStruct )->GenCopy(); - break; - - case SCH_JUNCTION_T: - NewDrawStruct = ( (SCH_JUNCTION*) aDrawStruct )->GenCopy(); - break; - - case SCH_MARKER_T: - NewDrawStruct = ( (SCH_MARKER*) aDrawStruct )->GenCopy(); - break; - - case SCH_NO_CONNECT_T: - NewDrawStruct = ( (SCH_NO_CONNECT*) aDrawStruct )->GenCopy(); - break; - - case SCH_TEXT_T: - NewDrawStruct = ( (SCH_TEXT*) aDrawStruct )->GenCopy(); - break; - - case SCH_LABEL_T: - NewDrawStruct = ( (SCH_LABEL*) aDrawStruct )->GenCopy(); - break; - - case SCH_HIERARCHICAL_LABEL_T: - NewDrawStruct = ( (SCH_HIERLABEL*) aDrawStruct )->GenCopy(); - break; - - case SCH_GLOBAL_LABEL_T: - NewDrawStruct = ( (SCH_GLOBALLABEL*) aDrawStruct )->GenCopy(); - break; - - case SCH_COMPONENT_T: - NewDrawStruct = ( (SCH_COMPONENT*) aDrawStruct )->GenCopy(); - break; - - case SCH_SHEET_T: - NewDrawStruct = ( (SCH_SHEET*) aDrawStruct )->GenCopy(); - if( aClone ) - { - ( (SCH_SHEET*) NewDrawStruct )->m_SheetName = - ( (SCH_SHEET*) aDrawStruct )->m_SheetName; - } - break; - - default: - { - wxString msg; - msg << wxT( "DuplicateStruct error: unexpected StructType " ) - << aDrawStruct->Type() << wxT( " " ) << aDrawStruct->GetClass(); - wxMessageBox( msg ); - } - break; - } + SCH_ITEM* NewDrawStruct = aDrawStruct->Clone(); if( aClone ) NewDrawStruct->m_TimeStamp = aDrawStruct->m_TimeStamp; NewDrawStruct->m_Image = aDrawStruct; + return NewDrawStruct; } diff --git a/eeschema/plot.cpp b/eeschema/plot.cpp index caac7a8d2b..8f6a4528f5 100644 --- a/eeschema/plot.cpp +++ b/eeschema/plot.cpp @@ -14,7 +14,10 @@ #include "protos.h" #include "class_library.h" #include "lib_pin.h" +#include "sch_bus_entry.h" #include "sch_items.h" +#include "sch_line.h" +#include "sch_no_connect.h" #include "sch_component.h" #include "sch_sheet.h" #include "sch_text.h" diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp new file mode 100644 index 0000000000..8da154947d --- /dev/null +++ b/eeschema/sch_bus_entry.cpp @@ -0,0 +1,246 @@ +/***********************/ +/* class SCH_BUS_ENTRY */ +/***********************/ + +#include "fctsys.h" +#include "gr_basic.h" +#include "macros.h" +#include "class_drawpanel.h" +#include "trigo.h" +#include "common.h" +#include "richio.h" + +#include "general.h" +#include "protos.h" +#include "sch_bus_entry.h" + + +SCH_BUS_ENTRY::SCH_BUS_ENTRY( const wxPoint& pos, int shape, int id ) : + SCH_ITEM( NULL, SCH_BUS_ENTRY_T ) +{ + m_Pos = pos; + m_Size.x = 100; + m_Size.y = 100; + m_Layer = LAYER_WIRE; + m_Width = 0; + + if( id == BUS_TO_BUS ) + { + m_Layer = LAYER_BUS; + } + + if( shape == '/' ) + m_Size.y = -100; +} + + +SCH_BUS_ENTRY::SCH_BUS_ENTRY( const SCH_BUS_ENTRY& aBusEntry ) : + SCH_ITEM( aBusEntry ) +{ + m_Pos = aBusEntry.m_Pos; + m_Size = aBusEntry.m_Size; + m_Width = aBusEntry.m_Width; +} + + +EDA_ITEM* SCH_BUS_ENTRY::doClone() const +{ + return new SCH_BUS_ENTRY( *this ); +} + + +wxPoint SCH_BUS_ENTRY::m_End() const +{ + return wxPoint( m_Pos.x + m_Size.x, m_Pos.y + m_Size.y ); +} + + +bool SCH_BUS_ENTRY::Save( FILE* aFile ) const +{ + bool success = true; + + const char* layer = "Wire"; + const char* width = "Line"; + + if( GetLayer() == LAYER_BUS ) + { + layer = "Bus"; width = "Bus"; + } + + if( fprintf( aFile, "Entry %s %s\n", layer, width ) == EOF ) + { + success = false; + } + if( fprintf( aFile, "\t%-4d %-4d %-4d %-4d\n", + m_Pos.x, m_Pos.y, m_End().x, m_End().y ) == EOF ) + { + success = false; + } + + return success; +} + + +bool SCH_BUS_ENTRY::Load( LINE_READER& aLine, wxString& aErrorMsg ) +{ + char Name1[256]; + char Name2[256]; + char* line = (char*) aLine; + + while( (*line != ' ' ) && *line ) + line++; + + if( sscanf( line, "%s %s", Name1, Name2 ) != 2 ) + { + aErrorMsg.Printf( wxT( "EESchema file bus entry load error at line %d" ), + aLine.LineNumber() ); + aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine ); + return false; + } + + m_Layer = LAYER_WIRE; + + if( Name1[0] == 'B' ) + m_Layer = LAYER_BUS; + + if( !aLine.ReadLine() || sscanf( (char*) aLine, "%d %d %d %d ", &m_Pos.x, &m_Pos.y, + &m_Size.x, &m_Size.y ) != 4 ) + { + aErrorMsg.Printf( wxT( "EESchema file bus entry load error at line %d" ), + aLine.LineNumber() ); + aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine ); + return false; + } + + m_Size.x -= m_Pos.x; + m_Size.y -= m_Pos.y; + + return true; +} + + +EDA_Rect SCH_BUS_ENTRY::GetBoundingBox() const +{ + EDA_Rect box; + + box.SetOrigin( m_Pos ); + box.SetEnd( m_End() ); + + box.Normalize(); + int width = ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width; + box.Inflate( width / 2 ); + + return box; +} + + +int SCH_BUS_ENTRY::GetPenSize() const +{ + int pensize = ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width; + + if( m_Layer == LAYER_BUS && m_Width == 0 ) + { + pensize = wxRound( g_DrawDefaultLineThickness * BUS_WIDTH_EXPAND ); + pensize = MAX( pensize, 3 ); + } + + return pensize; +} + + +void SCH_BUS_ENTRY::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, + int aDrawMode, int aColor ) +{ + int color; + + if( aColor >= 0 ) + color = aColor; + else + color = ReturnLayerColor( m_Layer ); + + GRSetDrawMode( aDC, aDrawMode ); + + GRLine( &aPanel->m_ClipBox, aDC, m_Pos.x + aOffset.x, m_Pos.y + aOffset.y, + m_End().x + aOffset.x, m_End().y + aOffset.y, GetPenSize(), color ); +} + + +void SCH_BUS_ENTRY::Mirror_X( int aXaxis_position ) +{ + m_Pos.y -= aXaxis_position; + NEGATE( m_Pos.y ); + m_Pos.y += aXaxis_position; + NEGATE( m_Size.y ); +} + + +void SCH_BUS_ENTRY::Mirror_Y( int aYaxis_position ) +{ + m_Pos.x -= aYaxis_position; + NEGATE( m_Pos.x ); + m_Pos.x += aYaxis_position; + NEGATE( m_Size.x ); +} + + +void SCH_BUS_ENTRY::Rotate( wxPoint rotationPoint ) +{ + RotatePoint( &m_Pos, rotationPoint, 900 ); + RotatePoint( &m_Size.x, &m_Size.y, 900 ); +} + + +void SCH_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) +{ + DANGLING_END_ITEM item( ENTRY_END, this ); + item.m_Pos = m_Pos; + + DANGLING_END_ITEM item1( ENTRY_END, this ); + item1.m_Pos = m_End(); + aItemList.push_back( item ); + aItemList.push_back( item1 ); +} + + +bool SCH_BUS_ENTRY::IsSelectStateChanged( const wxRect& aRect ) +{ + bool previousState = IsSelected(); + + // If either end of the bus entry is inside the selection rectangle, the entire + // bus entry is selected. Bus entries have a fixed length and angle. + if( aRect.Contains( m_Pos ) || aRect.Contains( m_End() ) ) + m_Flags |= SELECTED; + else + m_Flags &= ~SELECTED; + + return previousState != IsSelected(); +} + + +void SCH_BUS_ENTRY::GetConnectionPoints( vector< wxPoint >& aPoints ) const +{ + aPoints.push_back( m_Pos ); + aPoints.push_back( m_End() ); +} + + +bool SCH_BUS_ENTRY::doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const +{ + if( !( aFilter & BUS_ENTRY_T ) ) + return false; + + return TestSegmentHit( aPoint, m_Pos, m_End(), aAccuracy ); +} + + +bool SCH_BUS_ENTRY::doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const +{ + EDA_Rect rect = aRect; + + rect.Inflate( aAccuracy ); + + if( aContained ) + return rect.Contains( GetBoundingBox() ); + + return rect.Intersects( GetBoundingBox() ); +} diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h new file mode 100644 index 0000000000..f4b669329a --- /dev/null +++ b/eeschema/sch_bus_entry.h @@ -0,0 +1,115 @@ +/** + * @file sch_bus_entry.h + * + */ + +#ifndef _SCH_BUS_ENTRY_H_ +#define _SCH_BUS_ENTRY_H_ + +#include "sch_item_struct.h" + + +/* Flags for BUS ENTRY (bus to bus or wire to bus */ +#define WIRE_TO_BUS 0 +#define BUS_TO_BUS 1 + + +/** + * Class SCH_BUS_ENTRY + * + * Defines a bus or wire entry. + */ +class SCH_BUS_ENTRY : public SCH_ITEM +{ +public: + int m_Width; + wxPoint m_Pos; + wxSize m_Size; + +public: + SCH_BUS_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), int shape = '\\', int id = WIRE_TO_BUS ); + + SCH_BUS_ENTRY( const SCH_BUS_ENTRY& aBusEntry ); + + ~SCH_BUS_ENTRY() { } + + virtual wxString GetClass() const + { + return wxT( "SCH_BUS_ENTRY" ); + } + + wxPoint m_End() const; + + virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, + int aDrawMode, int aColor = -1 ); + + /** + * Function Save + * writes the data structures for this object out to a FILE in "*.sch" + * format. + * @param aFile The FILE to write to. + * @return bool - true if success writing else false. + */ + bool Save( FILE* aFile ) const; + + /** + * Load schematic bus entry from \a aLine in a .sch file. + * + * @param aLine - Essentially this is file to read schematic bus entry from. + * @param aErrorMsg - Description of the error if an error occurs while loading the + * schematic bus entry. + * @return True if the schematic bus entry loaded successfully. + */ + virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); + + /** + * Function GetBoundingBox + * returns the orthogonal, bounding box of this object for display + * purposes. This box should be an enclosing perimeter for visible + * components of this object, and the units should be in the pcb or + * schematic coordinate system. It is OK to overestimate the size + * by a few counts. + */ + EDA_Rect GetBoundingBox() const; + + /** + * Function GetPenSize + * @return the size of the "pen" that be used to draw or plot this item + */ + virtual int GetPenSize() const; + + /** + * Function Move + * moves and item to a new position by \a aMoveVector. + * @param aMoveVector The displacement vector. + */ + virtual void Move( const wxPoint& aMoveVector ) + { + m_Pos += aMoveVector; + } + + /** + * Function Mirror_Y + * mirrors the item relative to \a aYaxis_position. + * @param aYaxis_position The Y axis coordinate to mirror around. + */ + virtual void Mirror_Y( int aYaxis_position ); + + virtual void Mirror_X( int aXaxis_position ); + + virtual void Rotate( wxPoint rotationPoint ); + + virtual void GetEndPoints( std::vector & aItemList ); + + virtual bool IsSelectStateChanged( const wxRect& aRect ); + + virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const; + +private: + virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; + virtual bool doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const; + virtual EDA_ITEM* doClone() const; +}; + + +#endif // _SCH_BUS_ENTRY_H_ diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 04d9fcc8bc..379cc4321c 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -130,20 +130,21 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_COMPONENT& libComponent, SCH_SHEET_PATH* sheet } -SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aTemplate ) : - SCH_ITEM( NULL, SCH_COMPONENT_T ) +SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aComponent ) : + SCH_ITEM( aComponent ) { - /* assignment of all fields, including field vector elements, and linked - * list pointers */ - *this = aTemplate; + m_Parent = aComponent.m_Parent; + m_Pos = aComponent.m_Pos; + m_unit = aComponent.m_unit; + m_convert = aComponent.m_convert; + m_ChipName = aComponent.m_ChipName; + m_TimeStamp = aComponent.m_TimeStamp; + m_transform = aComponent.m_transform; + m_prefix = aComponent.m_prefix; + m_PathsAndReferences = aComponent.m_PathsAndReferences; + m_Fields = aComponent.m_Fields; - /* set linked list pointers to null, before this they were copies of - * aTemplate's */ - Pback = NULL; - Pnext = NULL; - m_Son = NULL; - - // Re-parent the fields, which before this had aTemplate as parent + // Re-parent the fields, which before this had aComponent as parent for( int i = 0; iSetParent( this ); @@ -180,6 +181,12 @@ void SCH_COMPONENT::Init( const wxPoint& pos ) } +EDA_ITEM* SCH_COMPONENT::doClone() const +{ + return new SCH_COMPONENT( *this ); +} + + void SCH_COMPONENT::SetLibName( const wxString& aName ) { if( m_ChipName != aName ) @@ -273,18 +280,18 @@ void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs { EDA_Rect BoundaryBox; BoundaryBox = GetBoundingBox(); - GRRect( &panel->m_ClipBox, DC, BoundaryBox, BROWN ); + GRRect( &panel->m_ClipBox, DC, BoundaryBox, 0, BROWN ); #if 1 if( GetField( REFERENCE )->IsVisible() ) { BoundaryBox = GetField( REFERENCE )->GetBoundingBox(); - GRRect( &panel->m_ClipBox, DC, BoundaryBox, BROWN ); + GRRect( &panel->m_ClipBox, DC, BoundaryBox, 0, BROWN ); } if( GetField( VALUE )->IsVisible() ) { BoundaryBox = GetField( VALUE )->GetBoundingBox(); - GRRect( &panel->m_ClipBox, DC, BoundaryBox, BROWN ); + GRRect( &panel->m_ClipBox, DC, BoundaryBox, 0, BROWN ); } #endif } @@ -1367,6 +1374,7 @@ EDA_Rect SCH_COMPONENT::GetBodyBoundingBox() const // H and W must be > 0: if( x2 < x1 ) EXCHG( x2, x1 ); + if( y2 < y1 ) EXCHG( y2, y1 ); @@ -1649,7 +1657,7 @@ LIB_DRAW_ITEM* SCH_COMPONENT::GetDrawItem( const wxPoint& aPosition, KICAD_T aTy } -bool SCH_COMPONENT::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const +bool SCH_COMPONENT::doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const { EDA_Rect bBox; @@ -1664,7 +1672,7 @@ bool SCH_COMPONENT::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_ bBox = GetField( ii )->GetBoundingBox(); bBox.Inflate( aAccuracy ); - if( bBox.Inside( aPoint ) ) + if( bBox.Contains( aPoint ) ) return true; } } @@ -1674,7 +1682,7 @@ bool SCH_COMPONENT::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_ bBox = GetBodyBoundingBox(); bBox.Inflate( aAccuracy ); - if( bBox.Inside( aPoint ) ) + if( bBox.Contains( aPoint ) ) return true; } @@ -1682,20 +1690,20 @@ bool SCH_COMPONENT::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_ } -bool SCH_COMPONENT::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const +bool SCH_COMPONENT::doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const { EDA_Rect rect = aRect; rect.Inflate( aAccuracy ); if( aContained ) - return rect.Inside( GetBoundingBox() ); + return rect.Contains( GetBoundingBox() ); return rect.Intersects( GetBoundingBox() ); } -bool SCH_COMPONENT::DoIsConnected( const wxPoint& aPosition ) const +bool SCH_COMPONENT::doIsConnected( const wxPoint& aPosition ) const { vector< wxPoint > pts; diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index 73fd89c415..89c41dd9b5 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -60,14 +60,11 @@ class SCH_COMPONENT : public SCH_ITEM TRANSFORM m_transform; ///< The rotation/mirror transformation matrix. SCH_FIELDS m_Fields; ///< Variable length list of fields. - /* Hierarchical references. - * format is - * path reference multi - * with: - * path = // (subsheet path, = / for the root sheet) - * reference = reference for this path (C23, R5, U78 ... ) - * multi = part selection in multi parts per package (0 or 1 for one part - * per package) + /** + * Defines the hierarchical path and reference of the component. This allowa support + * for hierarchical sheets that reference the same schematic. The foramt for the path + * is /<sheet time stamp>/<sheet time stamp>/... A single / denotes the root + * sheet. */ wxArrayString m_PathsAndReferences; @@ -103,12 +100,12 @@ public: /** * Copy Constructor - * clones \a aTemplate into this object. All fields are copied as is except + * clones \a aComponent into a new object. All fields are copied as is except * for the linked list management pointers which are set to NULL, and the * SCH_FIELD's m_Parent pointers which are set to the new parent, * i.e. this new object. */ - SCH_COMPONENT( const SCH_COMPONENT& aTemplate ); + SCH_COMPONENT( const SCH_COMPONENT& aComponent ); ~SCH_COMPONENT() { } @@ -152,16 +149,6 @@ public: */ virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); - /** - * Function GenCopy - * returns a copy of this object but with the linked list pointers set to NULL. - * @return SCH_COMPONENT* - a copy of me. - */ - SCH_COMPONENT* GenCopy() const - { - return new SCH_COMPONENT( *this ); - } - /** * Function SetOrientation * computes the new transform matrix based on \a aOrientation for the component which is @@ -260,7 +247,6 @@ public: m_Fields = aFields; // vector copying, length is changed possibly } - //--------------------------------------------------------------- /** @@ -409,9 +395,10 @@ public: #endif private: - virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; - virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const; - virtual bool DoIsConnected( const wxPoint& aPosition ) const; + virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; + virtual bool doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const; + virtual bool doIsConnected( const wxPoint& aPosition ) const; + virtual EDA_ITEM* doClone() const; }; diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index f98aa17781..5f71360b11 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -29,8 +29,7 @@ #include "template_fieldnames.h" -SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, - SCH_COMPONENT* aParent, wxString aName ) : +SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, wxString aName ) : SCH_ITEM( aParent, SCH_FIELD_T ), EDA_TextStruct() { @@ -44,15 +43,27 @@ SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, } +SCH_FIELD::SCH_FIELD( const SCH_FIELD& aField ) : + SCH_ITEM( aField ), + EDA_TextStruct( aField ) +{ + m_FieldId = aField.m_FieldId; + m_Name = aField.m_Name; + m_AddExtraText = aField.m_AddExtraText; +} + + SCH_FIELD::~SCH_FIELD() { } -/** - * Function GetPenSize - * @return the size of the "pen" that be used to draw or plot this item - */ +EDA_ITEM* SCH_FIELD::doClone() const +{ + return new SCH_FIELD( *this ); +} + + int SCH_FIELD::GetPenSize() const { int pensize = m_Thickness; @@ -71,9 +82,6 @@ int SCH_FIELD::GetPenSize() const } -/** - * Draw schematic component fields. - */ void SCH_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int DrawMode, int Color ) { @@ -103,6 +111,7 @@ void SCH_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, /* Calculate the text orientation, according to the component * orientation/mirror */ orient = m_Orient; + if( parentComponent->GetTransform().y1 ) // Rotate component 90 degrees. { if( orient == TEXT_ORIENT_HORIZ ) @@ -136,9 +145,7 @@ void SCH_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, if( !m_AddExtraText || ( m_FieldId != REFERENCE ) ) { - DrawGraphicText( panel, DC, textpos, color, m_Text, - orient, - m_Size, hjustify, vjustify, + DrawGraphicText( panel, DC, textpos, color, m_Text, orient, m_Size, hjustify, vjustify, LineWidth, m_Italic, m_Bold ); } else @@ -148,9 +155,7 @@ void SCH_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, wxString fulltext = m_Text; fulltext << LIB_COMPONENT::ReturnSubReference( parentComponent->GetUnit() ); - DrawGraphicText( panel, DC, textpos, color, fulltext, - orient, - m_Size, hjustify, vjustify, + DrawGraphicText( panel, DC, textpos, color, fulltext, orient, m_Size, hjustify, vjustify, LineWidth, m_Italic, m_Bold ); } @@ -182,13 +187,6 @@ void SCH_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, } -/** - * Function ImportValues - * copy parameters from a source. - * Pointers and specific values (position, texts) are not copied - * used to init a field from the model read from a lib entry - * @param aSource = the LIB_FIELD to read - */ void SCH_FIELD::ImportValues( const LIB_FIELD& aSource ) { m_Orient = aSource.m_Orient; @@ -197,38 +195,29 @@ void SCH_FIELD::ImportValues( const LIB_FIELD& aSource ) m_VJustify = aSource.m_VJustify; m_Italic = aSource.m_Italic; m_Bold = aSource.m_Bold; - m_Thickness = aSource.m_Thickness; + m_Thickness = aSource.m_Thickness; m_Attributs = aSource.m_Attributs; m_Mirror = aSource.m_Mirror; } -/** - * Used if undo / redo command: - * swap data between this and copyitem - */ -void SCH_FIELD::SwapData( SCH_FIELD* copyitem ) +void SCH_FIELD::SwapData( SCH_FIELD* aField ) { - EXCHG( m_Text, copyitem->m_Text ); - EXCHG( m_Layer, copyitem->m_Layer ); - EXCHG( m_Pos, copyitem->m_Pos ); - EXCHG( m_Size, copyitem->m_Size ); - EXCHG( m_Thickness, copyitem->m_Thickness ); - EXCHG( m_Orient, copyitem->m_Orient ); - EXCHG( m_Mirror, copyitem->m_Mirror ); - EXCHG( m_Attributs, copyitem->m_Attributs ); - EXCHG( m_Italic, copyitem->m_Italic ); - EXCHG( m_Bold, copyitem->m_Bold ); - EXCHG( m_HJustify, copyitem->m_HJustify ); - EXCHG( m_VJustify, copyitem->m_VJustify ); + EXCHG( m_Text, aField->m_Text ); + EXCHG( m_Layer, aField->m_Layer ); + EXCHG( m_Pos, aField->m_Pos ); + EXCHG( m_Size, aField->m_Size ); + EXCHG( m_Thickness, aField->m_Thickness ); + EXCHG( m_Orient, aField->m_Orient ); + EXCHG( m_Mirror, aField->m_Mirror ); + EXCHG( m_Attributs, aField->m_Attributs ); + EXCHG( m_Italic, aField->m_Italic ); + EXCHG( m_Bold, aField->m_Bold ); + EXCHG( m_HJustify, aField->m_HJustify ); + EXCHG( m_VJustify, aField->m_VJustify ); } -/** - * Function GetBoundaryBox - * @return an EDA_Rect contains the real (user coordinates) boundary box for a text field. - * according to the component position, rotation, mirror ... - */ EDA_Rect SCH_FIELD::GetBoundingBox() const { EDA_Rect BoundaryBox; @@ -459,7 +448,7 @@ void SCH_FIELD::Rotate( wxPoint rotationPoint ) } -bool SCH_FIELD::DoHitTest( const wxPoint& aPoint, int aAccuracy ) const +bool SCH_FIELD::doHitTest( const wxPoint& aPoint, int aAccuracy ) const { // Do not hit test hidden fields. if( !IsVisible() ) @@ -469,11 +458,11 @@ bool SCH_FIELD::DoHitTest( const wxPoint& aPoint, int aAccuracy ) const rect.Inflate( aAccuracy ); - return rect.Inside( aPoint ); + return rect.Contains( aPoint ); } -bool SCH_FIELD::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const +bool SCH_FIELD::doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const { // Do not hit test hidden fields. if( !IsVisible() ) @@ -484,7 +473,7 @@ bool SCH_FIELD::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy rect.Inflate( aAccuracy ); if( aContained ) - return rect.Inside( GetBoundingBox() ); + return rect.Contains( GetBoundingBox() ); return rect.Intersects( GetBoundingBox() ); } diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h index 2de7135500..7699ae94fb 100644 --- a/eeschema/sch_field.h +++ b/eeschema/sch_field.h @@ -5,14 +5,6 @@ #ifndef CLASS_SCH_FIELD_H #define CLASS_SCH_FIELD_H -/* Fields are texts attached to a component, having a special meaning - * Fields 0 and 1 are very important: reference and value - * Field 2 is used as default footprint name. - * Field 3 is reserved (not currently used - * Fields 4 and more are user fields. - * They can be renamed and can appear in reports - */ - #include "sch_item_struct.h" #include "general.h" @@ -25,11 +17,16 @@ class LIB_FIELD; /** * Class SCH_FIELD - * instances are attached to a component and provide a place for the - * component's value, - * reference designator, footprint, and user definable name-value pairs of - * arbitrary purpose. + * instances are attached to a component and provide a place for the component's value, + * reference designator, footprint, and user definable name-value pairs of arbitrary purpose. + * + *
  • Field 0 is reserved for the component reference.
  • + *
  • Field 1 is reserved for the component value.
  • + *
  • Field 2 is reserved for the component footprint.
  • + *
  • Field 3 is reserved for the component data sheet file.
  • + *
  • Fields 4 and higher are user defineable.
*/ + class SCH_FIELD : public SCH_ITEM, public EDA_TextStruct { public: @@ -44,6 +41,8 @@ public: SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent, wxString aName = wxEmptyString ); + SCH_FIELD( const SCH_FIELD& aField ); + ~SCH_FIELD(); virtual wxString GetClass() const @@ -66,8 +65,13 @@ public: return len == 0 || ( len == 1 && m_Text[0] == wxChar( '~' ) ); } - - void SwapData( SCH_FIELD* copyitem ); + /** + * Function SwapData + * exchanges the date between the field and \a aField. + * + * @param aField The field to exchange data with. + */ + void SwapData( SCH_FIELD* aField ); /** * Function ImportValues @@ -160,8 +164,9 @@ public: void* aAuxData, wxPoint * aFindLocation ); private: - virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy ) const; - virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const; + virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const; + virtual bool doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const; + virtual EDA_ITEM* doClone() const; }; diff --git a/eeschema/sch_items.cpp b/eeschema/sch_items.cpp index c27ffd90bb..98758718aa 100644 --- a/eeschema/sch_items.cpp +++ b/eeschema/sch_items.cpp @@ -14,265 +14,13 @@ #include "protos.h" #include "sch_items.h" -#include - - -/* used to calculate the pen size from default value - * the actual pen size is default value * BUS_WIDTH_EXPAND - */ -#if defined(KICAD_GOST) -#define BUS_WIDTH_EXPAND 3.6 -#else -#define BUS_WIDTH_EXPAND 1.4 -#endif - -/***********************/ -/* class SCH_BUS_ENTRY */ -/***********************/ - -SCH_BUS_ENTRY::SCH_BUS_ENTRY( const wxPoint& pos, int shape, int id ) : - SCH_ITEM( NULL, SCH_BUS_ENTRY_T ) -{ - m_Pos = pos; - m_Size.x = 100; - m_Size.y = 100; - m_Layer = LAYER_WIRE; - m_Width = 0; - - if( id == BUS_TO_BUS ) - { - m_Layer = LAYER_BUS; - } - - if( shape == '/' ) - m_Size.y = -100; -} - - -wxPoint SCH_BUS_ENTRY::m_End() const -{ - return wxPoint( m_Pos.x + m_Size.x, m_Pos.y + m_Size.y ); -} - - -SCH_BUS_ENTRY* SCH_BUS_ENTRY::GenCopy() -{ - SCH_BUS_ENTRY* newitem = new SCH_BUS_ENTRY( m_Pos, 0, 0 ); - - newitem->m_Layer = m_Layer; - newitem->m_Width = m_Width; - newitem->m_Size = m_Size; - newitem->m_Flags = m_Flags; - - return newitem; -} - - -/** - * Function Save - * writes the data structures for this object out to a FILE in "*.sch" format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ -bool SCH_BUS_ENTRY::Save( FILE* aFile ) const -{ - bool success = true; - - const char* layer = "Wire"; - const char* width = "Line"; - - if( GetLayer() == LAYER_BUS ) - { - layer = "Bus"; width = "Bus"; - } - - if( fprintf( aFile, "Entry %s %s\n", layer, width ) == EOF ) - { - success = false; - } - if( fprintf( aFile, "\t%-4d %-4d %-4d %-4d\n", - m_Pos.x, m_Pos.y, m_End().x, m_End().y ) == EOF ) - { - success = false; - } - - return success; -} - - -bool SCH_BUS_ENTRY::Load( LINE_READER& aLine, wxString& aErrorMsg ) -{ - char Name1[256]; - char Name2[256]; - char* line = (char*) aLine; - - while( (*line != ' ' ) && *line ) - line++; - - if( sscanf( line, "%s %s", Name1, Name2 ) != 2 ) - { - aErrorMsg.Printf( wxT( "EESchema file bus entry load error at line %d" ), - aLine.LineNumber() ); - aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine ); - return false; - } - - m_Layer = LAYER_WIRE; - - if( Name1[0] == 'B' ) - m_Layer = LAYER_BUS; - - if( !aLine.ReadLine() || sscanf( (char*) aLine, "%d %d %d %d ", &m_Pos.x, &m_Pos.y, - &m_Size.x, &m_Size.y ) != 4 ) - { - aErrorMsg.Printf( wxT( "EESchema file bus entry load error at line %d" ), - aLine.LineNumber() ); - aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine ); - return false; - } - - m_Size.x -= m_Pos.x; - m_Size.y -= m_Pos.y; - - return true; -} - - -EDA_Rect SCH_BUS_ENTRY::GetBoundingBox() const -{ - EDA_Rect box; - - box.SetOrigin( m_Pos ); - box.SetEnd( m_End() ); - - box.Normalize(); - int width = ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width; - box.Inflate( width / 2 ); - - return box; -} - - -/** - * Function GetPenSize - * @return the size of the "pen" that be used to draw or plot this item - */ -int SCH_BUS_ENTRY::GetPenSize() const -{ - int pensize = ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width; - - if( m_Layer == LAYER_BUS && m_Width == 0 ) - { - pensize = wxRound( g_DrawDefaultLineThickness * BUS_WIDTH_EXPAND ); - pensize = MAX( pensize, 3 ); - } - - return pensize; -} - - -void SCH_BUS_ENTRY::Draw( WinEDA_DrawPanel* panel, wxDC* DC, - const wxPoint& offset, int DrawMode, int Color ) -{ - int color; - - if( Color >= 0 ) - color = Color; - else - color = ReturnLayerColor( m_Layer ); - GRSetDrawMode( DC, DrawMode ); - - GRLine( &panel->m_ClipBox, DC, m_Pos.x + offset.x, m_Pos.y + offset.y, - m_End().x + offset.x, m_End().y + offset.y, GetPenSize(), color ); -} - - -void SCH_BUS_ENTRY::Mirror_X( int aXaxis_position ) -{ - m_Pos.y -= aXaxis_position; - NEGATE( m_Pos.y ); - m_Pos.y += aXaxis_position; - NEGATE( m_Size.y ); -} - - -void SCH_BUS_ENTRY::Mirror_Y( int aYaxis_position ) -{ - m_Pos.x -= aYaxis_position; - NEGATE( m_Pos.x ); - m_Pos.x += aYaxis_position; - NEGATE( m_Size.x ); -} - - -void SCH_BUS_ENTRY::Rotate( wxPoint rotationPoint ) -{ - RotatePoint( &m_Pos, rotationPoint, 900 ); - RotatePoint( &m_Size.x, &m_Size.y, 900 ); -} - - -void SCH_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) -{ - DANGLING_END_ITEM item( ENTRY_END, this ); - item.m_Pos = m_Pos; - - DANGLING_END_ITEM item1( ENTRY_END, this ); - item1.m_Pos = m_End(); - aItemList.push_back( item ); - aItemList.push_back( item1 ); -} - - -bool SCH_BUS_ENTRY::IsSelectStateChanged( const wxRect& aRect ) -{ - bool previousState = IsSelected(); - - // If either end of the bus entry is inside the selection rectangle, the entire - // bus entry is selected. Bus entries have a fixed length and angle. - if( aRect.Contains( m_Pos ) || aRect.Contains( m_End() ) ) - m_Flags |= SELECTED; - else - m_Flags &= ~SELECTED; - - return previousState != IsSelected(); -} - - -void SCH_BUS_ENTRY::GetConnectionPoints( vector< wxPoint >& aPoints ) const -{ - aPoints.push_back( m_Pos ); - aPoints.push_back( m_End() ); -} - - -bool SCH_BUS_ENTRY::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const -{ - if( !( aFilter & BUS_ENTRY_T ) ) - return false; - - return TestSegmentHit( aPoint, m_Pos, m_End(), aAccuracy ); -} - - -bool SCH_BUS_ENTRY::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const -{ - EDA_Rect rect = aRect; - - rect.Inflate( aAccuracy ); - - if( aContained ) - return rect.Inside( GetBoundingBox() ); - - return rect.Intersects( GetBoundingBox() ); -} - /**********************/ /* class SCH_JUNCTION */ /**********************/ -SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos ) : SCH_ITEM( NULL, SCH_JUNCTION_T ) +SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos ) : + SCH_ITEM( NULL, SCH_JUNCTION_T ) { #define DRAWJUNCTION_DIAMETER 32 /* Diameter of junction symbol between wires */ m_Pos = pos; @@ -282,6 +30,14 @@ SCH_JUNCTION::SCH_JUNCTION( const wxPoint& pos ) : SCH_ITEM( NULL, SCH_JUNCTION_ } +SCH_JUNCTION::SCH_JUNCTION( const SCH_JUNCTION& aJunction ) : + SCH_ITEM( aJunction ) +{ + m_Pos = aJunction.m_Pos; + m_Size = aJunction.m_Size; +} + + SCH_JUNCTION* SCH_JUNCTION::GenCopy() { SCH_JUNCTION* newitem = new SCH_JUNCTION( m_Pos ); @@ -294,12 +50,6 @@ SCH_JUNCTION* SCH_JUNCTION::GenCopy() } -/** - * Function Save - * writes the data structures for this object out to a FILE in "*.sch" format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ bool SCH_JUNCTION::Save( FILE* aFile ) const { bool success = true; @@ -313,6 +63,12 @@ bool SCH_JUNCTION::Save( FILE* aFile ) const } +EDA_ITEM* SCH_JUNCTION::doClone() const +{ + return new SCH_JUNCTION( *this ); +} + + bool SCH_JUNCTION::Load( LINE_READER& aLine, wxString& aErrorMsg ) { char name[256]; @@ -344,23 +100,20 @@ EDA_Rect SCH_JUNCTION::GetBoundingBox() const } -/***************************************************************************** -* Routine to redraw connection struct. * -*****************************************************************************/ -void SCH_JUNCTION::Draw( WinEDA_DrawPanel* panel, wxDC* DC, - const wxPoint& offset, int DrawMode, int Color ) +void SCH_JUNCTION::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, + int aDrawMode, int aColor ) { int color; - if( Color >= 0 ) - color = Color; + if( aColor >= 0 ) + color = aColor; else color = ReturnLayerColor( m_Layer ); - GRSetDrawMode( DC, DrawMode ); - GRFilledCircle( &panel->m_ClipBox, DC, m_Pos.x + offset.x, - m_Pos.y + offset.y, (m_Size.x / 2), 0, color, - color ); + GRSetDrawMode( aDC, aDrawMode ); + + GRFilledCircle( &aPanel->m_ClipBox, aDC, m_Pos.x + aOffset.x, m_Pos.y + aOffset.y, + ( m_Size.x / 2 ), 0, color, color ); } @@ -424,7 +177,7 @@ void SCH_JUNCTION::Show( int nestLevel, std::ostream& os ) #endif -bool SCH_JUNCTION::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const +bool SCH_JUNCTION::doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const { if( !( aFilter & JUNCTION_T ) ) return false; @@ -433,852 +186,24 @@ bool SCH_JUNCTION::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T rect.Inflate( aAccuracy ); - return rect.Inside( aPoint ); + return rect.Contains( aPoint ); } -bool SCH_JUNCTION::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const +bool SCH_JUNCTION::doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const { EDA_Rect rect = aRect; rect.Inflate( aAccuracy ); if( aContained ) - return rect.Inside( GetBoundingBox() ); + return rect.Contains( GetBoundingBox() ); return rect.Intersects( GetBoundingBox() ); } -bool SCH_JUNCTION::DoIsConnected( const wxPoint& aPosition ) const +bool SCH_JUNCTION::doIsConnected( const wxPoint& aPosition ) const { return m_Pos == aPosition; } - - -/************************/ -/* class SCH_NO_CONNECT */ -/************************/ - -SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) : SCH_ITEM( NULL, SCH_NO_CONNECT_T ) -{ -#define DRAWNOCONNECT_SIZE 48 /* No symbol connection range. */ - m_Pos = pos; - m_Size.x = m_Size.y = DRAWNOCONNECT_SIZE; -#undef DRAWNOCONNECT_SIZE -} - - -SCH_NO_CONNECT* SCH_NO_CONNECT::GenCopy() -{ - SCH_NO_CONNECT* newitem = new SCH_NO_CONNECT( m_Pos ); - - newitem->m_Size = m_Size; - newitem->m_Flags = m_Flags; - - return newitem; -} - - -EDA_Rect SCH_NO_CONNECT::GetBoundingBox() const -{ - int delta = ( GetPenSize() + m_Size.x ) / 2; - EDA_Rect box; - - box.SetOrigin( m_Pos ); - box.Inflate( delta ); - - return box; -} - - -/** - * Function Save - * writes the data structures for this object out to a FILE in "*.sch" format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ -bool SCH_NO_CONNECT::Save( FILE* aFile ) const -{ - bool success = true; - - if( fprintf( aFile, "NoConn ~ %-4d %-4d\n", m_Pos.x, m_Pos.y ) == EOF ) - { - success = false; - } - - return success; -} - - -bool SCH_NO_CONNECT::Load( LINE_READER& aLine, wxString& aErrorMsg ) -{ - char name[256]; - char* line = (char*) aLine; - - while( (*line != ' ' ) && *line ) - line++; - - if( sscanf( line, "%s %d %d", name, &m_Pos.x, &m_Pos.y ) != 3 ) - { - aErrorMsg.Printf( wxT( "EESchema file No Connect load error at line %d" ), - aLine.LineNumber() ); - aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( ((char*)aLine) ); - return false; - } - - return true; -} - - -/** - * Function GetPenSize - * @return the size of the "pen" that be used to draw or plot this item - */ -int SCH_NO_CONNECT::GetPenSize() const -{ - return g_DrawDefaultLineThickness; -} - - -void SCH_NO_CONNECT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, - const wxPoint& offset, int DrawMode, int Color ) -{ - int pX, pY, color; - int delta = m_Size.x / 2; - int width = g_DrawDefaultLineThickness; - - pX = m_Pos.x + offset.x; - pY = m_Pos.y + offset.y; - - if( Color >= 0 ) - color = Color; - else - color = ReturnLayerColor( LAYER_NOCONNECT ); - GRSetDrawMode( DC, DrawMode ); - - GRLine( &panel->m_ClipBox, DC, pX - delta, pY - delta, pX + delta, - pY + delta, width, color ); - GRLine( &panel->m_ClipBox, DC, pX + delta, pY - delta, pX - delta, - pY + delta, width, color ); -} - - -void SCH_NO_CONNECT::Mirror_X( int aXaxis_position ) -{ - m_Pos.y -= aXaxis_position; - NEGATE( m_Pos.y ); - m_Pos.y += aXaxis_position; -} - - -void SCH_NO_CONNECT::Mirror_Y( int aYaxis_position ) -{ - m_Pos.x -= aYaxis_position; - NEGATE( m_Pos.x ); - m_Pos.x += aYaxis_position; -} - - -void SCH_NO_CONNECT::Rotate( wxPoint rotationPoint ) -{ - RotatePoint( &m_Pos, rotationPoint, 900 ); -} - - -bool SCH_NO_CONNECT::IsSelectStateChanged( const wxRect& aRect ) -{ - bool previousState = IsSelected(); - - if( aRect.Contains( m_Pos ) ) - m_Flags |= SELECTED; - else - m_Flags &= ~SELECTED; - - return previousState != IsSelected(); -} - - -void SCH_NO_CONNECT::GetConnectionPoints( vector< wxPoint >& aPoints ) const -{ - aPoints.push_back( m_Pos ); -} - - -bool SCH_NO_CONNECT::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const -{ - if( !( aFilter & NO_CONNECT_T ) ) - return false; - - int delta = ( ( m_Size.x + g_DrawDefaultLineThickness ) / 2 ) + aAccuracy; - - wxPoint dist = aPoint - m_Pos; - - if( ( ABS( dist.x ) <= delta ) && ( ABS( dist.y ) <= delta ) ) - return true; - - return false; -} - - -bool SCH_NO_CONNECT::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const -{ - EDA_Rect rect = aRect; - - rect.Inflate( aAccuracy ); - - if( aContained ) - return rect.Inside( GetBoundingBox() ); - - return rect.Intersects( GetBoundingBox() ); -} - - -/******************/ -/* Class SCH_LINE */ -/******************/ - -SCH_LINE::SCH_LINE( const wxPoint& pos, int layer ) : - SCH_ITEM( NULL, SCH_LINE_T ) -{ - m_Start = pos; - m_End = pos; - m_Width = 0; // Default thickness used - m_StartIsDangling = m_EndIsDangling = FALSE; - - switch( layer ) - { - default: - m_Layer = LAYER_NOTES; - break; - - case LAYER_WIRE: - m_Layer = LAYER_WIRE; - break; - - case LAYER_BUS: - m_Layer = LAYER_BUS; - break; - } -} - - -SCH_LINE* SCH_LINE::GenCopy() -{ - SCH_LINE* newitem = new SCH_LINE( m_Start, m_Layer ); - - newitem->m_End = m_End; - - return newitem; -} - - -void SCH_LINE::Move( const wxPoint& aOffset ) -{ - if( (m_Flags & STARTPOINT) == 0 && aOffset != wxPoint( 0, 0 ) ) - { - m_Start += aOffset; - SetModified(); - } - - if( (m_Flags & ENDPOINT) == 0 && aOffset != wxPoint( 0, 0 ) ) - { - m_End += aOffset; - SetModified(); - } -} - - -#if defined(DEBUG) - -/** - * Function Show - * is used to output the object tree, currently for debugging only. - * @param nestLevel An aid to prettier tree indenting, and is the level - * of nesting of this object within the overall tree. - * @param os The ostream& to output to. - */ -void SCH_LINE::Show( int nestLevel, std::ostream& os ) const -{ - NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() - << " layer=\"" << m_Layer << '"' - << " width=\"" << m_Width << '"' - << " startIsDangling=\"" << m_StartIsDangling - << '"' << " endIsDangling=\"" - << m_EndIsDangling << '"' << ">" - << " " - << " " << "\n"; -} - - -#endif - - -EDA_Rect SCH_LINE::GetBoundingBox() const -{ - int width = 25; - - int xmin = MIN( m_Start.x, m_End.x ) - width; - int ymin = MIN( m_Start.y, m_End.y ) - width; - - int xmax = MAX( m_Start.x, m_End.x ) + width; - int ymax = MAX( m_Start.y, m_End.y ) + width; - - // return a rectangle which is [pos,dim) in nature. therefore the +1 - EDA_Rect ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) ); - - return ret; -} - - -/** - * Function Save - * writes the data structures for this object out to a FILE in "*.sch" format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ -bool SCH_LINE::Save( FILE* aFile ) const -{ - bool success = true; - - const char* layer = "Notes"; - const char* width = "Line"; - - if( GetLayer() == LAYER_WIRE ) - layer = "Wire"; - - if( GetLayer() == LAYER_BUS ) - layer = "Bus"; - - if( fprintf( aFile, "Wire %s %s\n", layer, width ) == EOF ) - { - success = false; - } - - if( fprintf( aFile, "\t%-4d %-4d %-4d %-4d\n", m_Start.x, m_Start.y, - m_End.x, m_End.y ) == EOF ) - { - success = false; - } - - return success; -} - - -bool SCH_LINE::Load( LINE_READER& aLine, wxString& aErrorMsg ) -{ - char Name1[256]; - char Name2[256]; - char* line = (char*) aLine; - - while( (*line != ' ' ) && *line ) - line++; - - if( sscanf( line, "%s %s", Name1, Name2 ) != 2 ) - { - aErrorMsg.Printf( wxT( "EESchema file segment error at line %d, aborted" ), - aLine.LineNumber() ); - aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine ); - return false; - } - - m_Layer = LAYER_NOTES; - - if( Name1[0] == 'W' ) - m_Layer = LAYER_WIRE; - - if( Name1[0] == 'B' ) - m_Layer = LAYER_BUS; - - if( !aLine.ReadLine() || sscanf( (char*) aLine, "%d %d %d %d ", - &m_Start.x, &m_Start.y, &m_End.x, &m_End.y ) != 4 ) - { - aErrorMsg.Printf( wxT( "EESchema file Segment struct error at line %d, aborted" ), - aLine.LineNumber() ); - aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine ); - return false; - } - - return true; -} - - -/** - * Function GetPenSize - * @return the size of the "pen" that be used to draw or plot this item - */ -int SCH_LINE::GetPenSize() const -{ - int pensize = ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width; - - if( m_Layer == LAYER_BUS && m_Width == 0 ) - { - pensize = wxRound( g_DrawDefaultLineThickness * BUS_WIDTH_EXPAND ); - pensize = MAX( pensize, 3 ); - } - - return pensize; -} - - -void SCH_LINE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, - int DrawMode, int Color ) -{ - int color; - int width = GetPenSize(); - - if( Color >= 0 ) - color = Color; - else - color = ReturnLayerColor( m_Layer ); - - GRSetDrawMode( DC, DrawMode ); - - if( m_Layer == LAYER_NOTES ) - GRDashedLine( &panel->m_ClipBox, DC, m_Start.x + offset.x, - m_Start.y + offset.y, m_End.x + offset.x, - m_End.y + offset.y, width, color ); - else - GRLine( &panel->m_ClipBox, DC, m_Start.x + offset.x, - m_Start.y + offset.y, m_End.x + offset.x, m_End.y + offset.y, - width, color ); - - if( m_StartIsDangling ) - DrawDanglingSymbol( panel, DC, m_Start + offset, color ); - - if( m_EndIsDangling ) - DrawDanglingSymbol( panel, DC, m_End + offset, color ); -} - - -void SCH_LINE::Mirror_X( int aXaxis_position ) -{ - m_Start.y -= aXaxis_position; - NEGATE( m_Start.y ); - m_Start.y += aXaxis_position; - m_End.y -= aXaxis_position; - NEGATE( m_End.y ); - m_End.y += aXaxis_position; -} - - -void SCH_LINE::Mirror_Y( int aYaxis_position ) -{ - m_Start.x -= aYaxis_position; - NEGATE( m_Start.x ); - m_Start.x += aYaxis_position; - m_End.x -= aYaxis_position; - NEGATE( m_End.x ); - m_End.x += aYaxis_position; -} - - -void SCH_LINE::Rotate( wxPoint rotationPoint ) -{ - RotatePoint( &m_Start, rotationPoint, 900 ); - RotatePoint( &m_End, rotationPoint, 900 ); -} - - -bool SCH_LINE::MergeOverlap( SCH_LINE* aLine ) -{ - wxCHECK_MSG( aLine != NULL && aLine->Type() == SCH_LINE_T, false, - wxT( "Cannot test line segment for overlap." ) ); - - if( this == aLine || GetLayer() != aLine->GetLayer() ) - return false; - - // Search for a common end, and modify coordinates to ensure RefSegm->m_End - // == TstSegm->m_Start - if( m_Start == aLine->m_Start ) - { - if( m_End == aLine->m_End ) - return true; - - EXCHG( m_Start, m_End ); - } - else if( m_Start == aLine->m_End ) - { - EXCHG( m_Start, m_End ); - EXCHG( aLine->m_Start, aLine->m_End ); - } - else if( m_End == aLine->m_End ) - { - EXCHG( aLine->m_Start, aLine->m_End ); - } - else if( m_End != aLine->m_Start ) - { - // No common end point, segments cannot be merged. - return false; - } - - /* Test alignment: */ - if( m_Start.y == m_End.y ) // Horizontal segment - { - if( aLine->m_Start.y == aLine->m_End.y ) - { - m_End = aLine->m_End; - return true; - } - } - else if( m_Start.x == m_End.x ) // Vertical segment - { - if( aLine->m_Start.x == aLine->m_End.x ) - { - m_End = aLine->m_End; - return true; - } - } - else - { - if( atan2( (double) ( m_Start.x - m_End.x ), (double) ( m_Start.y - m_End.y ) ) - == atan2( (double) ( aLine->m_Start.x - aLine->m_End.x ), - (double) ( aLine->m_Start.y - aLine->m_End.y ) ) ) - { - m_End = aLine->m_End; - return true; - } - } - - return false; -} - - -void SCH_LINE::GetEndPoints( std::vector & aItemList ) -{ - if( GetLayer() == LAYER_NOTES ) - return; - - if( ( GetLayer() == LAYER_BUS ) || ( GetLayer() == LAYER_WIRE ) ) - { - DANGLING_END_ITEM item( (GetLayer() == LAYER_BUS) ? BUS_START_END : WIRE_START_END, this ); - item.m_Pos = m_Start; - DANGLING_END_ITEM item1( (GetLayer() == LAYER_BUS) ? BUS_END_END : WIRE_END_END, this ); - item1.m_Pos = m_End; - - aItemList.push_back( item ); - aItemList.push_back( item1 ); - } -} - - -bool SCH_LINE::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList ) -{ - bool previousStartState = m_StartIsDangling; - bool previousEndState = m_EndIsDangling; - - m_StartIsDangling = m_EndIsDangling = true; - - if( GetLayer() == LAYER_WIRE ) - { - BOOST_FOREACH( DANGLING_END_ITEM item, aItemList ) - { - if( item.m_Item == this ) - continue; - - if( m_Start == item.m_Pos ) - m_StartIsDangling = false; - - if( m_End == item.m_Pos ) - m_EndIsDangling = false; - - if( (m_StartIsDangling == false) && (m_EndIsDangling == false) ) - break; - } - } - else if( GetLayer() == LAYER_BUS || GetLayer() == LAYER_NOTES ) - { - // Lines on the notes layer and the bus layer cannot be tested for dangling ends. - previousStartState = previousEndState = m_StartIsDangling = m_EndIsDangling = false; - } - - return ( previousStartState != m_StartIsDangling ) || ( previousEndState != m_EndIsDangling ); -} - - -bool SCH_LINE::IsSelectStateChanged( const wxRect& aRect ) -{ - bool previousState = IsSelected(); - - if( aRect.Contains( m_Start ) ) - m_Flags |= STARTPOINT | SELECTED; - else - m_Flags &= ~( STARTPOINT | SELECTED ); - - if( aRect.Contains( m_End ) ) - m_Flags |= ENDPOINT | SELECTED; - else - m_Flags &= ~( ENDPOINT | SELECTED ); - - return previousState != IsSelected(); -} - - -void SCH_LINE::GetConnectionPoints( vector< wxPoint >& aPoints ) const -{ - aPoints.push_back( m_Start ); - aPoints.push_back( m_End ); -} - - -bool SCH_LINE::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const -{ - if( !( aFilter & ( DRAW_ITEM_T | WIRE_T | BUS_T ) ) ) - return false; - - if( ( ( aFilter & DRAW_ITEM_T ) && ( m_Layer == LAYER_NOTES ) ) - || ( ( aFilter & WIRE_T ) && ( m_Layer == LAYER_WIRE ) ) - || ( ( aFilter & BUS_T ) && ( m_Layer == LAYER_BUS ) ) ) - { - if( ( aFilter & EXCLUDE_WIRE_BUS_ENDPOINTS && IsEndPoint( aPoint ) ) - || ( aFilter & WIRE_BUS_ENDPOINTS_ONLY && !IsEndPoint( aPoint ) ) - || ( TestSegmentHit( aPoint, m_Start, m_End, aAccuracy ) ) ) - return true; - } - - return false; -} - - -bool SCH_LINE::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const -{ - EDA_Rect rect = aRect; - - rect.Inflate( aAccuracy ); - - if( aContained ) - return rect.Inside( GetBoundingBox() ); - - return rect.Intersects( GetBoundingBox() ); -} - - -bool SCH_LINE::DoIsConnected( const wxPoint& aPosition ) const -{ - if( m_Layer != LAYER_WIRE && m_Layer != LAYER_BUS ) - return false; - - return IsEndPoint( aPosition ); -} - - -/**********************/ -/* Class SCH_POLYLINE */ -/**********************/ - -SCH_POLYLINE::SCH_POLYLINE( int layer ) : SCH_ITEM( NULL, SCH_POLYLINE_T ) -{ - m_Width = 0; - - switch( layer ) - { - default: - m_Layer = LAYER_NOTES; - break; - - case LAYER_WIRE: - case LAYER_NOTES: - case LAYER_BUS: - m_Layer = layer; - break; - } -} - - -SCH_POLYLINE::~SCH_POLYLINE() -{ -} - - -SCH_POLYLINE* SCH_POLYLINE::GenCopy() -{ - SCH_POLYLINE* newitem = new SCH_POLYLINE( m_Layer ); - - newitem->m_PolyPoints = m_PolyPoints; // std::vector copy - return newitem; -} - - -/** - * Function Save - * writes the data structures for this object out to a FILE in "*.sch" format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ -bool SCH_POLYLINE::Save( FILE* aFile ) const -{ - bool success = true; - - const char* layer = "Notes"; - const char* width = "Line"; - - if( GetLayer() == LAYER_WIRE ) - layer = "Wire"; - if( GetLayer() == LAYER_BUS ) - layer = "Bus"; - if( fprintf( aFile, "Poly %s %s %d\n", width, layer, GetCornerCount() ) == EOF ) - { - return false; - } - for( unsigned ii = 0; ii < GetCornerCount(); ii++ ) - { - if( fprintf( aFile, "\t%-4d %-4d\n", m_PolyPoints[ii ].x, m_PolyPoints[ii].y ) == EOF ) - { - success = false; - break; - } - } - - return success; -} - - -bool SCH_POLYLINE::Load( LINE_READER& aLine, wxString& aErrorMsg ) -{ - char Name1[256]; - char Name2[256]; - wxPoint pt; - int ii; - char* line = (char*) aLine; - - while( (*line != ' ' ) && *line ) - line++; - - if( sscanf( line, "%s %s %d", Name1, Name2, &ii ) != 3 ) - { - aErrorMsg.Printf( wxT( "EESchema file polyline struct error at line %d, aborted" ), - aLine.LineNumber() ); - aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine ); - return false; - } - - m_Layer = LAYER_NOTES; - if( Name2[0] == 'W' ) - m_Layer = LAYER_WIRE; - if( Name2[0] == 'B' ) - m_Layer = LAYER_BUS; - - for( unsigned jj = 0; jj < (unsigned)ii; jj++ ) - { - wxPoint point; - - if( !aLine.ReadLine() || sscanf( ((char*) aLine), "%d %d", &pt.x, &pt.y ) != 2 ) - { - aErrorMsg.Printf( wxT( "EESchema file polyline struct error at line %d, aborted" ), - aLine.LineNumber() ); - aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine ); - return false; - } - - AddPoint( pt ); - } - - return true; -} - - -/** - * Function GetPenSize - * @return the size of the "pen" that be used to draw or plot this item - */ -int SCH_POLYLINE::GetPenSize() const -{ - int pensize = ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width; - - return pensize; -} - - -void SCH_POLYLINE::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, - int aDrawMode, int aColor ) -{ - int color; - int width = GetPenSize(); - - if( aColor >= 0 ) - color = aColor; - else - color = ReturnLayerColor( m_Layer ); - - GRSetDrawMode( aDC, aDrawMode ); - - if( m_Layer == LAYER_BUS ) - { - width *= 3; - } - - GRMoveTo( m_PolyPoints[0].x, m_PolyPoints[0].y ); - - if( m_Layer == LAYER_NOTES ) - { - for( unsigned i = 1; i < GetCornerCount(); i++ ) - GRDashedLineTo( &aPanel->m_ClipBox, aDC, m_PolyPoints[i].x + aOffset.x, - m_PolyPoints[i].y + aOffset.y, width, color ); - } - else - { - for( unsigned i = 1; i < GetCornerCount(); i++ ) - GRLineTo( &aPanel->m_ClipBox, aDC, m_PolyPoints[i].x + aOffset.x, - m_PolyPoints[i].y + aOffset.y, width, color ); - } -} - - -void SCH_POLYLINE::Mirror_X( int aXaxis_position ) -{ - for( unsigned ii = 0; ii < GetCornerCount(); ii++ ) - { - m_PolyPoints[ii].y -= aXaxis_position; - NEGATE( m_PolyPoints[ii].y ); - m_PolyPoints[ii].y = aXaxis_position; - } -} - - -void SCH_POLYLINE::Mirror_Y( int aYaxis_position ) -{ - for( unsigned ii = 0; ii < GetCornerCount(); ii++ ) - { - m_PolyPoints[ii].x -= aYaxis_position; - NEGATE( m_PolyPoints[ii].x ); - m_PolyPoints[ii].x = aYaxis_position; - } -} - - -void SCH_POLYLINE::Rotate( wxPoint rotationPoint ) -{ - for( unsigned ii = 0; ii < GetCornerCount(); ii++ ) - { - RotatePoint( &m_PolyPoints[ii], rotationPoint, 900 ); - } -} - - -bool SCH_POLYLINE::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const -{ - if( !( aFilter & ( DRAW_ITEM_T | WIRE_T | BUS_T ) ) ) - return false; - - for( size_t i = 0; i < m_PolyPoints.size() - 1; i++ ) - { - if( TestSegmentHit( aPoint, m_PolyPoints[i], m_PolyPoints[i + 1], aAccuracy ) ) - return true; - } - - return false; -} - - -bool SCH_POLYLINE::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const -{ - EDA_Rect rect = aRect; - - rect.Inflate( aAccuracy ); - - if( aContained ) - return rect.Inside( GetBoundingBox() ); - - return rect.Intersects( GetBoundingBox() ); -} diff --git a/eeschema/sch_items.h b/eeschema/sch_items.h index b6542b071e..223cde7763 100644 --- a/eeschema/sch_items.h +++ b/eeschema/sch_items.h @@ -1,412 +1,14 @@ -/************************************************************************/ -/* classes to handle items used in schematic: wires, bus, junctions ... */ -/************************************************************************/ +/** + * @file sch_item.h + * + */ -#ifndef CLASS_SCHEMATIC_ITEMS_H -#define CLASS_SCHEMATIC_ITEMS_H +#ifndef _SCH_ITEMS_H_ +#define _SCH_ITEMS_H_ #include "sch_item_struct.h" -#include "general.h" - - -/* Flags for BUS ENTRY (bus to bus or wire to bus */ -#define WIRE_TO_BUS 0 -#define BUS_TO_BUS 1 - - -/** - * Class SCH_LINE - * is a segment description base class to describe items which have 2 end - * points (track, wire, draw line ...) - */ -class SCH_LINE : public SCH_ITEM -{ -public: - int m_Width; // 0 = line, > 0 = tracks, bus ... - wxPoint m_Start; // Line start point - wxPoint m_End; // Line end point - - bool m_StartIsDangling; - bool m_EndIsDangling; // TRUE if not connected (wires, tracks...) - -public: - SCH_LINE( const wxPoint& pos = wxPoint( 0, 0 ), int layer = LAYER_NOTES ); - ~SCH_LINE() { } - - SCH_LINE* Next() const { return (SCH_LINE*) Pnext; } - SCH_LINE* Back() const { return (SCH_LINE*) Pback; } - - virtual wxString GetClass() const - { - return wxT( "SCH_LINE" ); - } - - bool IsEndPoint( const wxPoint& aPoint ) const - { - return aPoint == m_Start || aPoint == m_End; - } - - SCH_LINE* GenCopy(); - - bool IsNull() const { return m_Start == m_End; } - - /** - * Function GetBoundingBox - * returns the orthogonal, bounding box of this object for display purposes. - * This box should be an enclosing perimeter for visible components of this - * object, and the units should be in the pcb or schematic coordinate system. - * It is OK to overestimate the size by a few counts. - */ - EDA_Rect GetBoundingBox() const; - - virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, - int aDrawMode, int aColor = -1 ); - - /** - * Function Save - * writes the data structures for this object out to a FILE in "*.sch" format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ - bool Save( FILE* aFile ) const; - - /** - * Load schematic line from \a aLine in a .sch file. - * - * @param aLine - Essentially this is file to read schematic line from. - * @param aErrorMsg - Description of the error if an error occurs while loading the - * schematic line. - * @return True if the schematic line loaded successfully. - */ - virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); - - /** - * Function GetPenSize - * @return the size of the "pen" that be used to draw or plot this item - */ - virtual int GetPenSize() const; - - // Geometric transforms (used in block operations): - - /** virtual function Move - * move item to a new position. - * @param aMoveVector = the displacement vector - */ - virtual void Move( const wxPoint& aMoveVector ); - - virtual void Mirror_X( int aXaxis_position ); - - /** virtual function Mirror_Y - * mirror item relative to an Y axis - * @param aYaxis_position = the y axis position - */ - virtual void Mirror_Y( int aYaxis_position ); - - virtual void Rotate( wxPoint rotationPoint ); - - /** - * Check line against \a aLine to see if it overlaps and merge if it does. - * - * This method will change the line to be equivalent of the line and \a aLine if the - * two lines overlap. This method is used to merge multple line segments into a single - * line. - * - * @param aLine - Line to compare. - * @return True if lines overlap and the line was merged with \a aLine. - */ - bool MergeOverlap( SCH_LINE* aLine ); - - virtual void GetEndPoints( std::vector & aItemList ); - - virtual bool IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList ); - - virtual bool IsDangling() const { return m_StartIsDangling || m_EndIsDangling; } - - virtual bool IsSelectStateChanged( const wxRect& aRect ); - - virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const; - -#if defined(DEBUG) - void Show( int nestLevel, std::ostream& os ) const; -#endif - -private: - virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; - virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const; - virtual bool DoIsConnected( const wxPoint& aPosition ) const; -}; - - -class SCH_NO_CONNECT : public SCH_ITEM -{ -public: - wxPoint m_Pos; /* XY coordinates of NoConnect. */ - wxSize m_Size; // size of this symbol - -public: - SCH_NO_CONNECT( const wxPoint& pos = wxPoint( 0, 0 ) ); - ~SCH_NO_CONNECT() { } - - virtual wxString GetClass() const - { - return wxT( "SCH_NO_CONNECT" ); - } - - SCH_NO_CONNECT* GenCopy(); - - /** - * Function GetPenSize - * @return the size of the "pen" that be used to draw or plot this item - */ - virtual int GetPenSize() const; - - virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& affset, - int aDrawMode, int aColor = -1 ); - - /** - * Function Save - * writes the data structures for this object out to a FILE in "*.sch" - * format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ - bool Save( FILE* aFile ) const; - - /** - * Load schematic no connect entry from \a aLine in a .sch file. - * - * @param aLine - Essentially this is file to read schematic no connect from. - * @param aErrorMsg - Description of the error if an error occurs while loading the - * schematic no connect. - * @return True if the schematic no connect loaded successfully. - */ - virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); - - /** - * Function GetBoundingBox - * returns the orthogonal, bounding box of this object for display - * purposes. This box should be an enclosing perimeter for visible - * components of this object, and the units should be in the pcb or - * schematic coordinate system. It is OK to overestimate the size - * by a few counts. - */ - EDA_Rect GetBoundingBox() const; - - // Geometric transforms (used in block operations): - - /** virtual function Move - * move item to a new position. - * @param aMoveVector = the displacement vector - */ - virtual void Move( const wxPoint& aMoveVector ) - { - m_Pos += aMoveVector; - } - - /** virtual function Mirror_Y - * mirror item relative to an Y axis - * @param aYaxis_position = the y axis position - */ - virtual void Mirror_Y( int aYaxis_position ); - virtual void Mirror_X( int aXaxis_position ); - virtual void Rotate( wxPoint rotationPoint ); - - virtual bool IsSelectStateChanged( const wxRect& aRect ); - - virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const; - -private: - virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; - virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const; -}; - - -/** - * Class SCH_BUS_ENTRY - * - * Defines a bus or wire entry. - */ -class SCH_BUS_ENTRY : public SCH_ITEM -{ -public: - int m_Width; - wxPoint m_Pos; - wxSize m_Size; - -public: - SCH_BUS_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), int shape = '\\', int id = WIRE_TO_BUS ); - ~SCH_BUS_ENTRY() { } - - virtual wxString GetClass() const - { - return wxT( "SCH_BUS_ENTRY" ); - } - - - SCH_BUS_ENTRY* GenCopy(); - - wxPoint m_End() const; - - virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, - int aDrawMode, int aColor = -1 ); - - /** - * Function Save - * writes the data structures for this object out to a FILE in "*.sch" - * format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ - bool Save( FILE* aFile ) const; - - /** - * Load schematic bus entry from \a aLine in a .sch file. - * - * @param aLine - Essentially this is file to read schematic bus entry from. - * @param aErrorMsg - Description of the error if an error occurs while loading the - * schematic bus entry. - * @return True if the schematic bus entry loaded successfully. - */ - virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); - - /** - * Function GetBoundingBox - * returns the orthogonal, bounding box of this object for display - * purposes. This box should be an enclosing perimeter for visible - * components of this object, and the units should be in the pcb or - * schematic coordinate system. It is OK to overestimate the size - * by a few counts. - */ - EDA_Rect GetBoundingBox() const; - - /** - * Function GetPenSize - * @return the size of the "pen" that be used to draw or plot this item - */ - virtual int GetPenSize() const; - - // Geometric transforms (used in block operations): - - /** virtual function Move - * move item to a new position. - * @param aMoveVector = the displacement vector - */ - virtual void Move( const wxPoint& aMoveVector ) - { - m_Pos += aMoveVector; - } - - - /** virtual function Mirror_Y - * mirror item relative to an Y axis - * @param aYaxis_position = the y axis position - */ - virtual void Mirror_Y( int aYaxis_position ); - virtual void Mirror_X( int aXaxis_position ); - virtual void Rotate( wxPoint rotationPoint ); - - virtual void GetEndPoints( std::vector & aItemList ); - - virtual bool IsSelectStateChanged( const wxRect& aRect ); - - virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const; - -private: - virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; - virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const; -}; - -class SCH_POLYLINE : public SCH_ITEM -{ -public: - int m_Width; /* Thickness */ - std::vector m_PolyPoints; // list of points (>= 2) - -public: - SCH_POLYLINE( int layer = LAYER_NOTES ); - ~SCH_POLYLINE(); - - virtual wxString GetClass() const - { - return wxT( "SCH_POLYLINE" ); - } - - - SCH_POLYLINE* GenCopy(); - - virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, - int aDrawMode, int aColor = -1 ); - - /** - * Function Save - * writes the data structures for this object out to a FILE in "*.sch" - * format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ - bool Save( FILE* aFile ) const; - - /** - * Load schematic poly line entry from \a aLine in a .sch file. - * - * @param aLine - Essentially this is file to read schematic poly line from. - * @param aErrorMsg - Description of the error if an error occurs while loading the - * schematic poly line. - * @return True if the schematic poly line loaded successfully. - */ - virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); - - /** - * Function AddPoint - * add a corner to m_PolyPoints - */ - void AddPoint( const wxPoint& point ) - { - m_PolyPoints.push_back( point ); - } - - - /** - * Function GetCornerCount - * @return the number of corners - */ - - unsigned GetCornerCount() const { return m_PolyPoints.size(); } - - /** - * Function GetPenSize - * @return the size of the "pen" that be used to draw or plot this item - */ - virtual int GetPenSize() const; - - // Geometric transforms (used in block operations): - - /** virtual function Move - * move item to a new position. - * @param aMoveVector = the displacement vector - */ - virtual void Move( const wxPoint& aMoveVector ) - { - for( unsigned ii = 0; ii < GetCornerCount(); ii++ ) - m_PolyPoints[ii] += aMoveVector; - } - - - /** virtual function Mirror_Y - * mirror item relative to an Y axis - * @param aYaxis_position = the y axis position - */ - virtual void Mirror_Y( int aYaxis_position ); - virtual void Mirror_X( int aXaxis_position ); - virtual void Rotate( wxPoint rotationPoint ); - -private: - virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; - virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const; -}; - class SCH_JUNCTION : public SCH_ITEM { @@ -416,6 +18,9 @@ public: public: SCH_JUNCTION( const wxPoint& pos = wxPoint( 0, 0 ) ); + + SCH_JUNCTION( const SCH_JUNCTION& aJunction ); + ~SCH_JUNCTION() { } virtual wxString GetClass() const @@ -457,24 +62,25 @@ public: */ virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); - // Geometric transforms (used in block operations): - - /** virtual function Move - * move item to a new position. - * @param aMoveVector = the displacement vector + /** + * Function Move + * moves then item to a new position by \a aMoveVector. + * @param aMoveVector The displacement vector. */ virtual void Move( const wxPoint& aMoveVector ) { m_Pos += aMoveVector; } - - /** virtual function Mirror_Y - * mirror item relative to an Y axis + /** + * Function Mirror_Y + * mirrors the item relative to \a aYaxis_position. * @param aYaxis_position = the y axis position */ virtual void Mirror_Y( int aYaxis_position ); + virtual void Mirror_X( int aXaxis_position ); + virtual void Rotate( wxPoint rotationPoint ); virtual void GetEndPoints( std::vector & aItemList ); @@ -485,14 +91,14 @@ public: #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ); - #endif private: - virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; - virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const; - virtual bool DoIsConnected( const wxPoint& aPosition ) const; + virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; + virtual bool doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const; + virtual bool doIsConnected( const wxPoint& aPosition ) const; + virtual EDA_ITEM* doClone() const; }; -#endif /* CLASS_SCHEMATIC_ITEMS_H */ +#endif // _SCH_ITEMS_H_ diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp new file mode 100644 index 0000000000..0cfb45f3f7 --- /dev/null +++ b/eeschema/sch_line.cpp @@ -0,0 +1,429 @@ +/******************/ +/* Class SCH_LINE */ +/******************/ + +#include "fctsys.h" +#include "gr_basic.h" +#include "macros.h" +#include "class_drawpanel.h" +#include "trigo.h" +#include "richio.h" + +#include "general.h" +#include "protos.h" +#include "sch_line.h" + +#include + + +SCH_LINE::SCH_LINE( const wxPoint& pos, int layer ) : + SCH_ITEM( NULL, SCH_LINE_T ) +{ + m_Start = pos; + m_End = pos; + m_Width = 0; // Default thickness used + m_StartIsDangling = m_EndIsDangling = FALSE; + + switch( layer ) + { + default: + m_Layer = LAYER_NOTES; + break; + + case LAYER_WIRE: + m_Layer = LAYER_WIRE; + break; + + case LAYER_BUS: + m_Layer = LAYER_BUS; + break; + } +} + + +SCH_LINE::SCH_LINE( const SCH_LINE& aLine ) : + SCH_ITEM( aLine ) +{ + m_Start = aLine.m_Start; + m_End = aLine.m_End; + m_Width = aLine.m_Width; + m_StartIsDangling = m_EndIsDangling = false; +} + + +EDA_ITEM* SCH_LINE::doClone() const +{ + return new SCH_LINE( *this ); +} + + +void SCH_LINE::Move( const wxPoint& aOffset ) +{ + if( (m_Flags & STARTPOINT) == 0 && aOffset != wxPoint( 0, 0 ) ) + { + m_Start += aOffset; + SetModified(); + } + + if( (m_Flags & ENDPOINT) == 0 && aOffset != wxPoint( 0, 0 ) ) + { + m_End += aOffset; + SetModified(); + } +} + + +#if defined(DEBUG) + +void SCH_LINE::Show( int nestLevel, std::ostream& os ) const +{ + NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() + << " layer=\"" << m_Layer << '"' + << " width=\"" << m_Width << '"' + << " startIsDangling=\"" << m_StartIsDangling + << '"' << " endIsDangling=\"" + << m_EndIsDangling << '"' << ">" + << " " + << " " << "\n"; +} + +#endif + + +EDA_Rect SCH_LINE::GetBoundingBox() const +{ + int width = 25; + + int xmin = MIN( m_Start.x, m_End.x ) - width; + int ymin = MIN( m_Start.y, m_End.y ) - width; + + int xmax = MAX( m_Start.x, m_End.x ) + width; + int ymax = MAX( m_Start.y, m_End.y ) + width; + + // return a rectangle which is [pos,dim) in nature. therefore the +1 + EDA_Rect ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) ); + + return ret; +} + + +bool SCH_LINE::Save( FILE* aFile ) const +{ + bool success = true; + + const char* layer = "Notes"; + const char* width = "Line"; + + if( GetLayer() == LAYER_WIRE ) + layer = "Wire"; + + if( GetLayer() == LAYER_BUS ) + layer = "Bus"; + + if( fprintf( aFile, "Wire %s %s\n", layer, width ) == EOF ) + { + success = false; + } + + if( fprintf( aFile, "\t%-4d %-4d %-4d %-4d\n", m_Start.x, m_Start.y, + m_End.x, m_End.y ) == EOF ) + { + success = false; + } + + return success; +} + + +bool SCH_LINE::Load( LINE_READER& aLine, wxString& aErrorMsg ) +{ + char Name1[256]; + char Name2[256]; + char* line = (char*) aLine; + + while( (*line != ' ' ) && *line ) + line++; + + if( sscanf( line, "%s %s", Name1, Name2 ) != 2 ) + { + aErrorMsg.Printf( wxT( "EESchema file segment error at line %d, aborted" ), + aLine.LineNumber() ); + aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine ); + return false; + } + + m_Layer = LAYER_NOTES; + + if( Name1[0] == 'W' ) + m_Layer = LAYER_WIRE; + + if( Name1[0] == 'B' ) + m_Layer = LAYER_BUS; + + if( !aLine.ReadLine() || sscanf( (char*) aLine, "%d %d %d %d ", + &m_Start.x, &m_Start.y, &m_End.x, &m_End.y ) != 4 ) + { + aErrorMsg.Printf( wxT( "EESchema file Segment struct error at line %d, aborted" ), + aLine.LineNumber() ); + aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine ); + return false; + } + + return true; +} + + +int SCH_LINE::GetPenSize() const +{ + int pensize = ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width; + + if( m_Layer == LAYER_BUS && m_Width == 0 ) + { + pensize = wxRound( g_DrawDefaultLineThickness * BUS_WIDTH_EXPAND ); + pensize = MAX( pensize, 3 ); + } + + return pensize; +} + + +void SCH_LINE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, + int DrawMode, int Color ) +{ + int color; + int width = GetPenSize(); + + if( Color >= 0 ) + color = Color; + else + color = ReturnLayerColor( m_Layer ); + + GRSetDrawMode( DC, DrawMode ); + + if( m_Layer == LAYER_NOTES ) + GRDashedLine( &panel->m_ClipBox, DC, m_Start.x + offset.x, + m_Start.y + offset.y, m_End.x + offset.x, + m_End.y + offset.y, width, color ); + else + GRLine( &panel->m_ClipBox, DC, m_Start.x + offset.x, + m_Start.y + offset.y, m_End.x + offset.x, m_End.y + offset.y, + width, color ); + + if( m_StartIsDangling ) + DrawDanglingSymbol( panel, DC, m_Start + offset, color ); + + if( m_EndIsDangling ) + DrawDanglingSymbol( panel, DC, m_End + offset, color ); +} + + +void SCH_LINE::Mirror_X( int aXaxis_position ) +{ + m_Start.y -= aXaxis_position; + NEGATE( m_Start.y ); + m_Start.y += aXaxis_position; + m_End.y -= aXaxis_position; + NEGATE( m_End.y ); + m_End.y += aXaxis_position; +} + + +void SCH_LINE::Mirror_Y( int aYaxis_position ) +{ + m_Start.x -= aYaxis_position; + NEGATE( m_Start.x ); + m_Start.x += aYaxis_position; + m_End.x -= aYaxis_position; + NEGATE( m_End.x ); + m_End.x += aYaxis_position; +} + + +void SCH_LINE::Rotate( wxPoint rotationPoint ) +{ + RotatePoint( &m_Start, rotationPoint, 900 ); + RotatePoint( &m_End, rotationPoint, 900 ); +} + + +bool SCH_LINE::MergeOverlap( SCH_LINE* aLine ) +{ + wxCHECK_MSG( aLine != NULL && aLine->Type() == SCH_LINE_T, false, + wxT( "Cannot test line segment for overlap." ) ); + + if( this == aLine || GetLayer() != aLine->GetLayer() ) + return false; + + // Search for a common end, and modify coordinates to ensure RefSegm->m_End + // == TstSegm->m_Start + if( m_Start == aLine->m_Start ) + { + if( m_End == aLine->m_End ) + return true; + + EXCHG( m_Start, m_End ); + } + else if( m_Start == aLine->m_End ) + { + EXCHG( m_Start, m_End ); + EXCHG( aLine->m_Start, aLine->m_End ); + } + else if( m_End == aLine->m_End ) + { + EXCHG( aLine->m_Start, aLine->m_End ); + } + else if( m_End != aLine->m_Start ) + { + // No common end point, segments cannot be merged. + return false; + } + + /* Test alignment: */ + if( m_Start.y == m_End.y ) // Horizontal segment + { + if( aLine->m_Start.y == aLine->m_End.y ) + { + m_End = aLine->m_End; + return true; + } + } + else if( m_Start.x == m_End.x ) // Vertical segment + { + if( aLine->m_Start.x == aLine->m_End.x ) + { + m_End = aLine->m_End; + return true; + } + } + else + { + if( atan2( (double) ( m_Start.x - m_End.x ), (double) ( m_Start.y - m_End.y ) ) + == atan2( (double) ( aLine->m_Start.x - aLine->m_End.x ), + (double) ( aLine->m_Start.y - aLine->m_End.y ) ) ) + { + m_End = aLine->m_End; + return true; + } + } + + return false; +} + + +void SCH_LINE::GetEndPoints( std::vector & aItemList ) +{ + if( GetLayer() == LAYER_NOTES ) + return; + + if( ( GetLayer() == LAYER_BUS ) || ( GetLayer() == LAYER_WIRE ) ) + { + DANGLING_END_ITEM item( (GetLayer() == LAYER_BUS) ? BUS_START_END : WIRE_START_END, this ); + item.m_Pos = m_Start; + DANGLING_END_ITEM item1( (GetLayer() == LAYER_BUS) ? BUS_END_END : WIRE_END_END, this ); + item1.m_Pos = m_End; + + aItemList.push_back( item ); + aItemList.push_back( item1 ); + } +} + + +bool SCH_LINE::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList ) +{ + bool previousStartState = m_StartIsDangling; + bool previousEndState = m_EndIsDangling; + + m_StartIsDangling = m_EndIsDangling = true; + + if( GetLayer() == LAYER_WIRE ) + { + BOOST_FOREACH( DANGLING_END_ITEM item, aItemList ) + { + if( item.m_Item == this ) + continue; + + if( m_Start == item.m_Pos ) + m_StartIsDangling = false; + + if( m_End == item.m_Pos ) + m_EndIsDangling = false; + + if( (m_StartIsDangling == false) && (m_EndIsDangling == false) ) + break; + } + } + else if( GetLayer() == LAYER_BUS || GetLayer() == LAYER_NOTES ) + { + // Lines on the notes layer and the bus layer cannot be tested for dangling ends. + previousStartState = previousEndState = m_StartIsDangling = m_EndIsDangling = false; + } + + return ( previousStartState != m_StartIsDangling ) || ( previousEndState != m_EndIsDangling ); +} + + +bool SCH_LINE::IsSelectStateChanged( const wxRect& aRect ) +{ + bool previousState = IsSelected(); + + if( aRect.Contains( m_Start ) ) + m_Flags |= STARTPOINT | SELECTED; + else + m_Flags &= ~( STARTPOINT | SELECTED ); + + if( aRect.Contains( m_End ) ) + m_Flags |= ENDPOINT | SELECTED; + else + m_Flags &= ~( ENDPOINT | SELECTED ); + + return previousState != IsSelected(); +} + + +void SCH_LINE::GetConnectionPoints( vector< wxPoint >& aPoints ) const +{ + aPoints.push_back( m_Start ); + aPoints.push_back( m_End ); +} + + +bool SCH_LINE::doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const +{ + if( !( aFilter & ( DRAW_ITEM_T | WIRE_T | BUS_T ) ) ) + return false; + + if( ( ( aFilter & DRAW_ITEM_T ) && ( m_Layer == LAYER_NOTES ) ) + || ( ( aFilter & WIRE_T ) && ( m_Layer == LAYER_WIRE ) ) + || ( ( aFilter & BUS_T ) && ( m_Layer == LAYER_BUS ) ) ) + { + if( ( aFilter & EXCLUDE_WIRE_BUS_ENDPOINTS && IsEndPoint( aPoint ) ) + || ( aFilter & WIRE_BUS_ENDPOINTS_ONLY && !IsEndPoint( aPoint ) ) + || ( TestSegmentHit( aPoint, m_Start, m_End, aAccuracy ) ) ) + return true; + } + + return false; +} + + +bool SCH_LINE::doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const +{ + EDA_Rect rect = aRect; + + rect.Inflate( aAccuracy ); + + if( aContained ) + return rect.Contains( GetBoundingBox() ); + + return rect.Intersects( GetBoundingBox() ); +} + + +bool SCH_LINE::doIsConnected( const wxPoint& aPosition ) const +{ + if( m_Layer != LAYER_WIRE && m_Layer != LAYER_BUS ) + return false; + + return IsEndPoint( aPosition ); +} diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h new file mode 100644 index 0000000000..3c81f5df60 --- /dev/null +++ b/eeschema/sch_line.h @@ -0,0 +1,136 @@ +/** + * @file sch_line.h + * + */ + +#ifndef _SCH_LINE_H_ +#define _SCH_LINE_H_ + + +#include "sch_item_struct.h" + + +/** + * Class SCH_LINE + * is a segment description base class to describe items which have 2 end + * points (track, wire, draw line ...) + */ +class SCH_LINE : public SCH_ITEM +{ + bool m_StartIsDangling; + bool m_EndIsDangling; // TRUE if not connected (wires, tracks...) + +public: + int m_Width; // 0 = line, > 0 = tracks, bus ... + wxPoint m_Start; // Line start point + wxPoint m_End; // Line end point + +public: + SCH_LINE( const wxPoint& pos = wxPoint( 0, 0 ), int layer = LAYER_NOTES ); + SCH_LINE( const SCH_LINE& aLine ); + ~SCH_LINE() { } + + SCH_LINE* Next() const { return (SCH_LINE*) Pnext; } + SCH_LINE* Back() const { return (SCH_LINE*) Pback; } + + virtual wxString GetClass() const + { + return wxT( "SCH_LINE" ); + } + + bool IsEndPoint( const wxPoint& aPoint ) const + { + return aPoint == m_Start || aPoint == m_End; + } + + bool IsNull() const { return m_Start == m_End; } + + /** + * Function GetBoundingBox + * returns the orthogonal, bounding box of this object for display purposes. + * This box should be an enclosing perimeter for visible components of this + * object, and the units should be in the pcb or schematic coordinate system. + * It is OK to overestimate the size by a few counts. + */ + EDA_Rect GetBoundingBox() const; + + virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, + int aDrawMode, int aColor = -1 ); + + /** + * Function Save + * writes the data structures for this object out to a FILE in "*.sch" format. + * @param aFile The FILE to write to. + * @return bool - true if success writing else false. + */ + bool Save( FILE* aFile ) const; + + /** + * Load schematic line from \a aLine in a .sch file. + * + * @param aLine - Essentially this is file to read schematic line from. + * @param aErrorMsg - Description of the error if an error occurs while loading the + * schematic line. + * @return True if the schematic line loaded successfully. + */ + virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); + + /** + * Function GetPenSize + * @return the size of the "pen" that be used to draw or plot this item + */ + virtual int GetPenSize() const; + + /** + * Function Move + * moves the item by \a aMoveVector. + * @param aMoveVector The displacement vector + */ + virtual void Move( const wxPoint& aMoveVector ); + + virtual void Mirror_X( int aXaxis_position ); + + /** + * Function Mirror_Y + * mirrors the item relative to \a aYaxis_position. + * @param aYaxis_position = the y axis position + */ + virtual void Mirror_Y( int aYaxis_position ); + + virtual void Rotate( wxPoint rotationPoint ); + + /** + * Check line against \a aLine to see if it overlaps and merge if it does. + * + * This method will change the line to be equivalent of the line and \a aLine if the + * two lines overlap. This method is used to merge multple line segments into a single + * line. + * + * @param aLine - Line to compare. + * @return True if lines overlap and the line was merged with \a aLine. + */ + bool MergeOverlap( SCH_LINE* aLine ); + + virtual void GetEndPoints( std::vector & aItemList ); + + virtual bool IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemList ); + + virtual bool IsDangling() const { return m_StartIsDangling || m_EndIsDangling; } + + virtual bool IsSelectStateChanged( const wxRect& aRect ); + + virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const; + +#if defined(DEBUG) + void Show( int nestLevel, std::ostream& os ) const; +#endif + +private: + virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; + virtual bool doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const; + virtual bool doIsConnected( const wxPoint& aPosition ) const; + virtual EDA_ITEM* doClone() const; +}; + + +#endif // _SCH_LINE_H_ diff --git a/eeschema/sch_marker.cpp b/eeschema/sch_marker.cpp index c5ba7996ea..c2b8e47e7f 100644 --- a/eeschema/sch_marker.cpp +++ b/eeschema/sch_marker.cpp @@ -44,19 +44,21 @@ SCH_MARKER::SCH_MARKER( const wxPoint& pos, const wxString& text ) : } +SCH_MARKER::SCH_MARKER( const SCH_MARKER& aMarker ) : + SCH_ITEM( aMarker ), + MARKER_BASE( aMarker ) +{ +} + + SCH_MARKER::~SCH_MARKER() { } -SCH_MARKER* SCH_MARKER::GenCopy() +EDA_ITEM* SCH_MARKER::doClone() const { - SCH_MARKER* newitem = new SCH_MARKER( GetPos(), GetReporter().GetMainText() ); - - newitem->SetMarkerType( GetMarkerType() ); - newitem->SetErrorLevel( GetErrorLevel() ); - - return newitem; + return new SCH_MARKER( *this ); } @@ -76,7 +78,6 @@ void SCH_MARKER::Show( int nestLevel, std::ostream& os ) << GetPos() << "/>\n"; } - #endif /** @@ -194,7 +195,7 @@ bool SCH_MARKER::IsSelectStateChanged( const wxRect& aRect ) } -bool SCH_MARKER::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const +bool SCH_MARKER::doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const { if( !( aFilter & MARKER_T ) ) return false; diff --git a/eeschema/sch_marker.h b/eeschema/sch_marker.h index a5480bef7f..b6bd2f246c 100644 --- a/eeschema/sch_marker.h +++ b/eeschema/sch_marker.h @@ -30,6 +30,7 @@ class SCH_MARKER : public SCH_ITEM, public MARKER_BASE public: SCH_MARKER(); SCH_MARKER( const wxPoint& aPos, const wxString& aText ); + SCH_MARKER( const SCH_MARKER& aMarker ); ~SCH_MARKER(); virtual wxString GetClass() const @@ -37,11 +38,8 @@ public: return wxT( "SCH_MARKER" ); } - SCH_MARKER* GenCopy(); - - virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, - const wxPoint& aOffset, int aDraw_mode, - int aColor = -1 ); + virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, + int aDraw_mode, int aColor = -1 ); /** * Function Save @@ -104,7 +102,8 @@ public: #endif - virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; + virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; + virtual EDA_ITEM* doClone() const; }; #endif /* _TYPE_SCH_MARKER_H_ */ diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp new file mode 100644 index 0000000000..bb3da13bd9 --- /dev/null +++ b/eeschema/sch_no_connect.cpp @@ -0,0 +1,182 @@ +/************************/ +/* Class SCH_NO_CONNECT */ +/************************/ + +#include "fctsys.h" +#include "gr_basic.h" +#include "macros.h" +#include "class_drawpanel.h" +#include "common.h" +#include "trigo.h" +#include "richio.h" + +#include "general.h" +#include "protos.h" +#include "sch_no_connect.h" + + +SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) : + SCH_ITEM( NULL, SCH_NO_CONNECT_T ) +{ +#define DRAWNOCONNECT_SIZE 48 /* No symbol connection range. */ + m_Pos = pos; + m_Size.x = m_Size.y = DRAWNOCONNECT_SIZE; +#undef DRAWNOCONNECT_SIZE +} + + +SCH_NO_CONNECT::SCH_NO_CONNECT( const SCH_NO_CONNECT& aNoConnect ) : + SCH_ITEM( aNoConnect ) +{ + m_Pos = aNoConnect.m_Pos; + m_Size = aNoConnect.m_Size; +} + + +EDA_ITEM* SCH_NO_CONNECT::doClone() const +{ + return new SCH_NO_CONNECT( *this ); +} + + +EDA_Rect SCH_NO_CONNECT::GetBoundingBox() const +{ + int delta = ( GetPenSize() + m_Size.x ) / 2; + EDA_Rect box; + + box.SetOrigin( m_Pos ); + box.Inflate( delta ); + + return box; +} + + +bool SCH_NO_CONNECT::Save( FILE* aFile ) const +{ + bool success = true; + + if( fprintf( aFile, "NoConn ~ %-4d %-4d\n", m_Pos.x, m_Pos.y ) == EOF ) + { + success = false; + } + + return success; +} + + +bool SCH_NO_CONNECT::Load( LINE_READER& aLine, wxString& aErrorMsg ) +{ + char name[256]; + char* line = (char*) aLine; + + while( (*line != ' ' ) && *line ) + line++; + + if( sscanf( line, "%s %d %d", name, &m_Pos.x, &m_Pos.y ) != 3 ) + { + aErrorMsg.Printf( wxT( "EESchema file No Connect load error at line %d" ), + aLine.LineNumber() ); + aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( ((char*)aLine) ); + return false; + } + + return true; +} + + +int SCH_NO_CONNECT::GetPenSize() const +{ + return g_DrawDefaultLineThickness; +} + + +void SCH_NO_CONNECT::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, + int aDrawMode, int aColor ) +{ + int pX, pY, color; + int delta = m_Size.x / 2; + int width = g_DrawDefaultLineThickness; + + pX = m_Pos.x + aOffset.x; + pY = m_Pos.y + aOffset.y; + + if( aColor >= 0 ) + color = aColor; + else + color = ReturnLayerColor( LAYER_NOCONNECT ); + + GRSetDrawMode( aDC, aDrawMode ); + + GRLine( &aPanel->m_ClipBox, aDC, pX - delta, pY - delta, pX + delta, pY + delta, width, color ); + GRLine( &aPanel->m_ClipBox, aDC, pX + delta, pY - delta, pX - delta, pY + delta, width, color ); +} + + +void SCH_NO_CONNECT::Mirror_X( int aXaxis_position ) +{ + m_Pos.y -= aXaxis_position; + NEGATE( m_Pos.y ); + m_Pos.y += aXaxis_position; +} + + +void SCH_NO_CONNECT::Mirror_Y( int aYaxis_position ) +{ + m_Pos.x -= aYaxis_position; + NEGATE( m_Pos.x ); + m_Pos.x += aYaxis_position; +} + + +void SCH_NO_CONNECT::Rotate( wxPoint rotationPoint ) +{ + RotatePoint( &m_Pos, rotationPoint, 900 ); +} + + +bool SCH_NO_CONNECT::IsSelectStateChanged( const wxRect& aRect ) +{ + bool previousState = IsSelected(); + + if( aRect.Contains( m_Pos ) ) + m_Flags |= SELECTED; + else + m_Flags &= ~SELECTED; + + return previousState != IsSelected(); +} + + +void SCH_NO_CONNECT::GetConnectionPoints( vector< wxPoint >& aPoints ) const +{ + aPoints.push_back( m_Pos ); +} + + +bool SCH_NO_CONNECT::doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const +{ + if( !( aFilter & NO_CONNECT_T ) ) + return false; + + int delta = ( ( m_Size.x + g_DrawDefaultLineThickness ) / 2 ) + aAccuracy; + + wxPoint dist = aPoint - m_Pos; + + if( ( ABS( dist.x ) <= delta ) && ( ABS( dist.y ) <= delta ) ) + return true; + + return false; +} + + +bool SCH_NO_CONNECT::doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const +{ + EDA_Rect rect = aRect; + + rect.Inflate( aAccuracy ); + + if( aContained ) + return rect.Contains( GetBoundingBox() ); + + return rect.Intersects( GetBoundingBox() ); +} diff --git a/eeschema/sch_no_connect.h b/eeschema/sch_no_connect.h new file mode 100644 index 0000000000..d858e5c7d1 --- /dev/null +++ b/eeschema/sch_no_connect.h @@ -0,0 +1,102 @@ +/** + * @file sch_no_connect.h + * + */ + +#ifndef _SCH_NO_CONNECT_H_ +#define _SCH_NO_CONNECT_H_ + + +#include "sch_item_struct.h" + + +class SCH_NO_CONNECT : public SCH_ITEM +{ +public: + wxPoint m_Pos; /* XY coordinates of NoConnect. */ + wxSize m_Size; // size of this symbol + +public: + SCH_NO_CONNECT( const wxPoint& pos = wxPoint( 0, 0 ) ); + + SCH_NO_CONNECT( const SCH_NO_CONNECT& aNoConnect ); + + ~SCH_NO_CONNECT() { } + + virtual wxString GetClass() const + { + return wxT( "SCH_NO_CONNECT" ); + } + + /** + * Function GetPenSize + * @return the size of the "pen" that be used to draw or plot this item + */ + virtual int GetPenSize() const; + + virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, + int aDrawMode, int aColor = -1 ); + + /** + * Function Save + * writes the data structures for this object out to a FILE in "*.sch" + * format. + * @param aFile The FILE to write to. + * @return bool - true if success writing else false. + */ + bool Save( FILE* aFile ) const; + + /** + * Load schematic no connect entry from \a aLine in a .sch file. + * + * @param aLine - Essentially this is file to read schematic no connect from. + * @param aErrorMsg - Description of the error if an error occurs while loading the + * schematic no connect. + * @return True if the schematic no connect loaded successfully. + */ + virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); + + /** + * Function GetBoundingBox + * returns the orthogonal, bounding box of this object for display + * purposes. This box should be an enclosing perimeter for visible + * components of this object, and the units should be in the pcb or + * schematic coordinate system. It is OK to overestimate the size + * by a few counts. + */ + EDA_Rect GetBoundingBox() const; + + // Geometric transforms (used in block operations): + + /** virtual function Move + * move item to a new position. + * @param aMoveVector = the displacement vector + */ + virtual void Move( const wxPoint& aMoveVector ) + { + m_Pos += aMoveVector; + } + + /** + * Function Mirror_Y + * mirrors item relative to \a aYaxis_position. + * @param aYaxis_position = the y axis position + */ + virtual void Mirror_Y( int aYaxis_position ); + + virtual void Mirror_X( int aXaxis_position ); + + virtual void Rotate( wxPoint rotationPoint ); + + virtual bool IsSelectStateChanged( const wxRect& aRect ); + + virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const; + +private: + virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; + virtual bool doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const; + virtual EDA_ITEM* doClone() const; +}; + + +#endif // _SCH_NO_CONNECT_H_ diff --git a/eeschema/sch_polyline.cpp b/eeschema/sch_polyline.cpp new file mode 100644 index 0000000000..dde120a4dc --- /dev/null +++ b/eeschema/sch_polyline.cpp @@ -0,0 +1,233 @@ +/**********************/ +/* Class SCH_POLYLINE */ +/**********************/ + +#include "fctsys.h" +#include "gr_basic.h" +#include "macros.h" +#include "class_drawpanel.h" +#include "trigo.h" +#include "common.h" +#include "richio.h" + +#include "general.h" +#include "protos.h" +#include "sch_polyline.h" + + +SCH_POLYLINE::SCH_POLYLINE( int layer ) : + SCH_ITEM( NULL, SCH_POLYLINE_T ) +{ + m_Width = 0; + + switch( layer ) + { + default: + m_Layer = LAYER_NOTES; + break; + + case LAYER_WIRE: + case LAYER_NOTES: + case LAYER_BUS: + m_Layer = layer; + break; + } +} + + +SCH_POLYLINE::SCH_POLYLINE( const SCH_POLYLINE& aPolyLine ) : + SCH_ITEM( aPolyLine ) +{ + m_Width = aPolyLine.m_Width; + m_PolyPoints = aPolyLine.m_PolyPoints; +} + + +SCH_POLYLINE::~SCH_POLYLINE() +{ +} + + +EDA_ITEM* SCH_POLYLINE::doClone() const +{ + return new SCH_POLYLINE( *this ); +} + + +bool SCH_POLYLINE::Save( FILE* aFile ) const +{ + bool success = true; + + const char* layer = "Notes"; + const char* width = "Line"; + + if( GetLayer() == LAYER_WIRE ) + layer = "Wire"; + + if( GetLayer() == LAYER_BUS ) + layer = "Bus"; + + if( fprintf( aFile, "Poly %s %s %d\n", width, layer, GetCornerCount() ) == EOF ) + { + return false; + } + + for( unsigned ii = 0; ii < GetCornerCount(); ii++ ) + { + if( fprintf( aFile, "\t%-4d %-4d\n", m_PolyPoints[ii ].x, m_PolyPoints[ii].y ) == EOF ) + { + success = false; + break; + } + } + + return success; +} + + +bool SCH_POLYLINE::Load( LINE_READER& aLine, wxString& aErrorMsg ) +{ + char Name1[256]; + char Name2[256]; + wxPoint pt; + int ii; + char* line = (char*) aLine; + + while( (*line != ' ' ) && *line ) + line++; + + if( sscanf( line, "%s %s %d", Name1, Name2, &ii ) != 3 ) + { + aErrorMsg.Printf( wxT( "EESchema file polyline struct error at line %d, aborted" ), + aLine.LineNumber() ); + aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine ); + return false; + } + + m_Layer = LAYER_NOTES; + + if( Name2[0] == 'W' ) + m_Layer = LAYER_WIRE; + + if( Name2[0] == 'B' ) + m_Layer = LAYER_BUS; + + for( unsigned jj = 0; jj < (unsigned)ii; jj++ ) + { + wxPoint point; + + if( !aLine.ReadLine() || sscanf( ((char*) aLine), "%d %d", &pt.x, &pt.y ) != 2 ) + { + aErrorMsg.Printf( wxT( "EESchema file polyline struct error at line %d, aborted" ), + aLine.LineNumber() ); + aErrorMsg << wxT( "\n" ) << CONV_FROM_UTF8( (char*) aLine ); + return false; + } + + AddPoint( pt ); + } + + return true; +} + + +int SCH_POLYLINE::GetPenSize() const +{ + int pensize = ( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width; + + return pensize; +} + + +void SCH_POLYLINE::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, + int aDrawMode, int aColor ) +{ + int color; + int width = GetPenSize(); + + if( aColor >= 0 ) + color = aColor; + else + color = ReturnLayerColor( m_Layer ); + + GRSetDrawMode( aDC, aDrawMode ); + + if( m_Layer == LAYER_BUS ) + { + width *= 3; + } + + GRMoveTo( m_PolyPoints[0].x, m_PolyPoints[0].y ); + + if( m_Layer == LAYER_NOTES ) + { + for( unsigned i = 1; i < GetCornerCount(); i++ ) + GRDashedLineTo( &aPanel->m_ClipBox, aDC, m_PolyPoints[i].x + aOffset.x, + m_PolyPoints[i].y + aOffset.y, width, color ); + } + else + { + for( unsigned i = 1; i < GetCornerCount(); i++ ) + GRLineTo( &aPanel->m_ClipBox, aDC, m_PolyPoints[i].x + aOffset.x, + m_PolyPoints[i].y + aOffset.y, width, color ); + } +} + + +void SCH_POLYLINE::Mirror_X( int aXaxis_position ) +{ + for( unsigned ii = 0; ii < GetCornerCount(); ii++ ) + { + m_PolyPoints[ii].y -= aXaxis_position; + NEGATE( m_PolyPoints[ii].y ); + m_PolyPoints[ii].y = aXaxis_position; + } +} + + +void SCH_POLYLINE::Mirror_Y( int aYaxis_position ) +{ + for( unsigned ii = 0; ii < GetCornerCount(); ii++ ) + { + m_PolyPoints[ii].x -= aYaxis_position; + NEGATE( m_PolyPoints[ii].x ); + m_PolyPoints[ii].x = aYaxis_position; + } +} + + +void SCH_POLYLINE::Rotate( wxPoint rotationPoint ) +{ + for( unsigned ii = 0; ii < GetCornerCount(); ii++ ) + { + RotatePoint( &m_PolyPoints[ii], rotationPoint, 900 ); + } +} + + +bool SCH_POLYLINE::doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const +{ + if( !( aFilter & ( DRAW_ITEM_T | WIRE_T | BUS_T ) ) ) + return false; + + for( size_t i = 0; i < m_PolyPoints.size() - 1; i++ ) + { + if( TestSegmentHit( aPoint, m_PolyPoints[i], m_PolyPoints[i + 1], aAccuracy ) ) + return true; + } + + return false; +} + + +bool SCH_POLYLINE::doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const +{ + EDA_Rect rect = aRect; + + rect.Inflate( aAccuracy ); + + if( aContained ) + return rect.Contains( GetBoundingBox() ); + + return rect.Intersects( GetBoundingBox() ); +} diff --git a/eeschema/sch_polyline.h b/eeschema/sch_polyline.h new file mode 100644 index 0000000000..f9d526d92c --- /dev/null +++ b/eeschema/sch_polyline.h @@ -0,0 +1,104 @@ +/** + * @file sch_polyline.h + * + */ + +#ifndef _SCH_POLYLINE_H_ +#define _SCH_POLYLINE_H_ + + +#include "sch_item_struct.h" + + +class SCH_POLYLINE : public SCH_ITEM +{ +public: + int m_Width; /* Thickness */ + std::vector m_PolyPoints; // list of points (>= 2) + +public: + SCH_POLYLINE( int layer = LAYER_NOTES ); + + SCH_POLYLINE( const SCH_POLYLINE& aPolyLine ); + + ~SCH_POLYLINE(); + + virtual wxString GetClass() const + { + return wxT( "SCH_POLYLINE" ); + } + + virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, + int aDrawMode, int aColor = -1 ); + + /** + * Function Save + * writes the data structures for this object out to a FILE in "*.sch" + * format. + * @param aFile The FILE to write to. + * @return bool - true if success writing else false. + */ + bool Save( FILE* aFile ) const; + + /** + * Load schematic poly line entry from \a aLine in a .sch file. + * + * @param aLine - Essentially this is file to read schematic poly line from. + * @param aErrorMsg - Description of the error if an error occurs while loading the + * schematic poly line. + * @return True if the schematic poly line loaded successfully. + */ + virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); + + /** + * Function AddPoint + * add a corner to m_PolyPoints + */ + void AddPoint( const wxPoint& point ) + { + m_PolyPoints.push_back( point ); + } + + /** + * Function GetCornerCount + * @return the number of corners + */ + + unsigned GetCornerCount() const { return m_PolyPoints.size(); } + + /** + * Function GetPenSize + * @return the size of the "pen" that be used to draw or plot this item + */ + virtual int GetPenSize() const; + + /** + * Function Move + * moves an item to a new position by \a aMoveVector. + * @param aMoveVector = the displacement vector + */ + virtual void Move( const wxPoint& aMoveVector ) + { + for( unsigned ii = 0; ii < GetCornerCount(); ii++ ) + m_PolyPoints[ii] += aMoveVector; + } + + /** + * Function Mirror_Y + * mirrors an item relative to \a aYaxis_position. + * @param aYaxis_position The y axis position to mirror around. + */ + virtual void Mirror_Y( int aYaxis_position ); + + virtual void Mirror_X( int aXaxis_position ); + + virtual void Rotate( wxPoint rotationPoint ); + +private: + virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; + virtual bool doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const; + virtual EDA_ITEM* doClone() const; +}; + + +#endif // _SCH_POLYLINE_H_ diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index fb906133a2..519e2de2ee 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -14,6 +14,7 @@ #include "protos.h" #include "class_library.h" #include "sch_items.h" +#include "sch_line.h" #include "sch_sheet.h" #include "sch_component.h" @@ -203,11 +204,7 @@ SCH_ITEM* SCH_SCREEN::ExtractWires( bool CreateCopy ) if( CreateCopy ) { - if( item->Type() == SCH_JUNCTION_T ) - new_item = ( (SCH_JUNCTION*) item )->GenCopy(); - else - new_item = ( (SCH_LINE*) item )->GenCopy(); - + new_item = item->Clone(); new_item->SetNext( GetDrawItems() ); SetDrawItems( new_item ); } diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 42596599a3..279973f6d1 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -41,6 +41,26 @@ SCH_SHEET::SCH_SHEET( const wxPoint& pos ) : SCH_ITEM( NULL, SCH_SHEET_T ) } +SCH_SHEET::SCH_SHEET( const SCH_SHEET& aSheet ) : + SCH_ITEM( aSheet ) +{ + m_Pos = aSheet.m_Pos; + m_TimeStamp = aSheet.m_TimeStamp; + m_SheetNameSize = aSheet.m_SheetNameSize; + m_FileNameSize = aSheet.m_FileNameSize; + m_AssociatedScreen = aSheet.m_AssociatedScreen; + m_SheetName = aSheet.m_SheetName; + m_FileName = aSheet.m_FileName; + m_labels = aSheet.m_labels; + + for( size_t i = 0; i < m_labels.size(); i++ ) + m_labels[i].SetParent( this ); + + if( m_AssociatedScreen ) + m_AssociatedScreen->m_RefCount++; +} + + SCH_SHEET::~SCH_SHEET() { // also, look at the associated sheet & its reference count @@ -55,12 +75,12 @@ SCH_SHEET::~SCH_SHEET() } -/** - * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ +EDA_ITEM* SCH_SHEET::doClone() const +{ + return new SCH_SHEET( *this ); +} + + bool SCH_SHEET::Save( FILE* aFile ) const { if( fprintf( aFile, "$Sheet\n" ) == EOF @@ -248,49 +268,6 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg ) } -/* creates a copy of a sheet - * The linked data itself (GetDrawItems()) is not duplicated - */ -SCH_SHEET* SCH_SHEET::GenCopy() -{ - SCH_SHEET* newitem = new SCH_SHEET( m_Pos ); - - newitem->m_Size = m_Size; - newitem->SetParent( m_Parent ); - newitem->m_TimeStamp = GetTimeStamp(); - - newitem->m_FileName = m_FileName; - newitem->m_FileNameSize = m_FileNameSize; - -/* newitem->m_SheetName = m_SheetName; m_SheetName must be unique for - * all sub sheets in a given sheet - * so we no not duplicate sheet - * name - */ - newitem->m_SheetNameSize = m_SheetNameSize; - - BOOST_FOREACH( SCH_SHEET_PIN& sheetPin, m_labels ) - { - SCH_SHEET_PIN* newSheetPin = sheetPin.GenCopy(); - newSheetPin->SetParent( newitem ); - newitem->GetSheetPins().push_back( newSheetPin ); - } - - newitem->renumberLabels(); - - /* don't copy screen data - just reference it. */ - newitem->m_AssociatedScreen = m_AssociatedScreen; - - if( m_AssociatedScreen ) - m_AssociatedScreen->m_RefCount++; - - return newitem; -} - - -/* Used if undo / redo command: - * swap data between this and copyitem - */ void SCH_SHEET::SwapData( SCH_SHEET* copyitem ) { EXCHG( m_Pos, copyitem->m_Pos ); @@ -487,20 +464,12 @@ SCH_SHEET_PIN* SCH_SHEET::GetLabel( const wxPoint& aPosition ) } -/** - * Function GetPenSize - * @return the size of the "pen" that be used to draw or plot this item - */ int SCH_SHEET::GetPenSize() const { return g_DrawDefaultLineThickness; } -/** - * Function GetSheetNamePosition - * @return the position of the anchor of sheet name text - */ wxPoint SCH_SHEET::GetSheetNamePosition() { wxPoint pos = m_Pos; @@ -517,10 +486,7 @@ wxPoint SCH_SHEET::GetSheetNamePosition() return pos; } -/** - * Function GetFileNamePosition - * @return the position of the anchor of filename text - */ + wxPoint SCH_SHEET::GetFileNamePosition() { wxPoint pos = m_Pos; @@ -538,16 +504,6 @@ wxPoint SCH_SHEET::GetFileNamePosition() } -/** - * Function Draw - * Draw the hierarchical sheet shape - * @param aPanel = the current DrawPanel - * @param aDc = the current Device Context - * @param aOffset = draw offset (usually wxPoint(0,0)) - * @param aDrawMode = draw mode - * @param aColor = color used to draw sheet. Usually -1 to use the normal - * color for sheet items - */ void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, int aDrawMode, int aColor ) { @@ -613,10 +569,6 @@ void SCH_SHEET::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, } -/** - * Function GetBoundingBox - * @return an EDA_Rect giving the bounding box of the sheet - */ EDA_Rect SCH_SHEET::GetBoundingBox() const { int dx, dy; @@ -637,11 +589,6 @@ EDA_Rect SCH_SHEET::GetBoundingBox() const } -/** - * Function ComponentCount - * count our own components, without the power components. - * @return the component count. - */ int SCH_SHEET::ComponentCount() { int n = 0; @@ -672,13 +619,6 @@ int SCH_SHEET::ComponentCount() } -/** - * Function SearchHierarchy - * search the existing hierarchy for an instance of screen "FileName". - * @param aFilename = the filename to find - * @param aFilename = a location to return a pointer to the screen (if found) - * @return bool if found, and a pointer to the screen - */ bool SCH_SHEET::SearchHierarchy( wxString aFilename, SCH_SCREEN** aScreen ) { if( m_AssociatedScreen ) @@ -708,17 +648,6 @@ bool SCH_SHEET::SearchHierarchy( wxString aFilename, SCH_SCREEN** aScreen ) } -/** - * Function LocatePathOfScreen - * search the existing hierarchy for an instance of screen "FileName". - * don't bother looking at the root sheet - it must be unique, - * no other references to its m_AssociatedScreen otherwise there would be - * loops - * in the hierarchy. - * @param aScreen = the SCH_SCREEN* screen that we search for - * @param aList = the SCH_SHEET_PATH* that must be used - * @return true if found - */ bool SCH_SHEET::LocatePathOfScreen( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aList ) { if( m_AssociatedScreen ) @@ -749,15 +678,6 @@ bool SCH_SHEET::LocatePathOfScreen( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aList ) } -/** - * Function Load. - * for the sheet: load the file m_FileName - * if a screen already exists, the file is already read. - * m_AssociatedScreen point on the screen, and its m_RefCount is incremented - * else creates a new associated screen and load the data file. - * @param aFrame = a SCH_EDIT_FRAME pointer to the maim schematic frame - * @return true if OK - */ bool SCH_SHEET::Load( SCH_EDIT_FRAME* aFrame ) { bool success = true; @@ -804,12 +724,6 @@ bool SCH_SHEET::Load( SCH_EDIT_FRAME* aFrame ) } -/** - * Function CountSheets - * calculates the number of sheets found in "this" - * this number includes the full subsheets count - * @return the full count of sheets+subsheets contained by "this" - */ int SCH_SHEET::CountSheets() { int count = 1; //1 = this!! @@ -837,17 +751,6 @@ wxString SCH_SHEET::GetFileName( void ) } -/** - * Function ChangeFileName - * Set a new filename and manage data and associated screen - * The main difficulty is the filename change in a complex hierarchy. - * - if new filename is not already used: change to the new name (and if an - * existing file is found, load it on request) - * - if new filename is already used (a complex hierarchy) : reference the - * sheet. - * @param aFileName = the new filename - * @param aFrame = the schematic frame - */ bool SCH_SHEET::ChangeFileName( SCH_EDIT_FRAME* aFrame, const wxString& aFileName ) { if( ( GetFileName() == aFileName ) && m_AssociatedScreen ) @@ -997,11 +900,6 @@ void SCH_SHEET::Mirror_X( int aXaxis_position ) } -/** - * Function Mirror_Y (virtual) - * mirror item relative to an Y axis - * @param aYaxis_position = the y axis position - */ void SCH_SHEET::Mirror_Y( int aYaxis_position ) { m_Pos.x -= aYaxis_position; @@ -1031,14 +929,7 @@ void SCH_SHEET::Resize( const wxSize& aSize ) } -/** Compare schematic sheet entry (filename and sheetname) against search string. - * @param aSearchData - Criteria to search against. - * @param aAuxData - a pointer on auxiliary data, not used here. - * @param aFindLocation - a wxPoint where to put the location of matched item. can be NULL. - * @return True if this item matches the search criteria. - */ -bool SCH_SHEET::Matches( wxFindReplaceData& aSearchData, - void* aAuxData, wxPoint * aFindLocation ) +bool SCH_SHEET::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ) { if( SCH_ITEM::Matches( m_FileName, aSearchData ) ) { @@ -1136,7 +1027,7 @@ void SCH_SHEET::GetConnectionPoints( vector< wxPoint >& aPoints ) const } -bool SCH_SHEET::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const +bool SCH_SHEET::doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const { if( !( aFilter & SHEET_T ) ) return false; @@ -1145,18 +1036,18 @@ bool SCH_SHEET::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aF rect.Inflate( aAccuracy ); - return rect.Inside( aPoint ); + return rect.Contains( aPoint ); } -bool SCH_SHEET::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const +bool SCH_SHEET::doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const { EDA_Rect rect = aRect; rect.Inflate( aAccuracy ); if( aContained ) - return rect.Inside( GetBoundingBox() ); + return rect.Contains( GetBoundingBox() ); return rect.Intersects( GetBoundingBox() ); } @@ -1182,4 +1073,3 @@ void SCH_SHEET::Show( int nestLevel, std::ostream& os ) } #endif - diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index bcee17c475..33b6842276 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -47,11 +47,15 @@ private: * orientation. */ + virtual EDA_ITEM* doClone() const; + public: SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString ); + SCH_SHEET_PIN( const SCH_SHEET_PIN& aSheetLabel ); + ~SCH_SHEET_PIN() { } virtual wxString GetClass() const @@ -59,10 +63,7 @@ public: return wxT( "SCH_SHEET_PIN" ); } - - bool operator ==( const SCH_SHEET_PIN* aPin ) const; - - SCH_SHEET_PIN* GenCopy(); + bool operator ==( const SCH_SHEET_PIN* aPin ) const; virtual void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, @@ -101,6 +102,12 @@ public: void SetNumber( int aNumber ); void SetEdge( int aEdge ); int GetEdge(); + + /** + * Function ConstraintOnEdge + * is used to adjust label position to egde based on proximity to vertical / horizontal edge + * of the parent sheet. + */ void ConstraintOnEdge( wxPoint Pos ); /** @@ -223,6 +230,9 @@ public: public: SCH_SHEET( const wxPoint& pos = wxPoint( 0, 0 ) ); + + SCH_SHEET( const SCH_SHEET& aSheet ); + ~SCH_SHEET(); virtual wxString GetClass() const @@ -250,8 +260,6 @@ public: void Place( SCH_EDIT_FRAME* frame, wxDC* DC ); - SCH_SHEET* GenCopy(); - void DisplayInfo( WinEDA_DrawFrame* frame ); /* there is no member for orientation in sch_sheet, to preserve file @@ -513,8 +521,9 @@ protected: void renumberLabels(); private: - virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; - virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const; + virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; + virtual bool doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const; + virtual EDA_ITEM* doClone() const; }; #endif /* CLASS_DRAWSHEET_H */ diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp index 47ef7efb60..fb856b8e4b 100644 --- a/eeschema/sch_sheet_pin.cpp +++ b/eeschema/sch_sheet_pin.cpp @@ -52,22 +52,20 @@ SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxStr } -SCH_SHEET_PIN* SCH_SHEET_PIN::GenCopy() +SCH_SHEET_PIN::SCH_SHEET_PIN( const SCH_SHEET_PIN& aSheetLabel ) : + SCH_HIERLABEL( aSheetLabel ) { - SCH_SHEET_PIN* newitem = new SCH_SHEET_PIN( (SCH_SHEET*) m_Parent, m_Pos, m_Text ); - - newitem->SetEdge( GetEdge() ); - newitem->m_Shape = m_Shape; - newitem->m_Size = m_Size; - newitem->SetNumber( GetNumber() ); - return newitem; + m_Number = aSheetLabel.m_Number; + m_Edge = aSheetLabel.m_Edge; } -/** SCH_SHEET_PIN::Draw is the same as SCH_HIERLABEL::Draw - * but the graphic icon is slightly different - * for INPUT type the icon is the OUTPUT shape of SCH_HIERLABEL - * for OUTPUT type the icon is the INPUT shape of SCH_HIERLABEL - */ + +EDA_ITEM* SCH_SHEET_PIN::doClone() const +{ + return new SCH_SHEET_PIN( *this ); +} + + void SCH_SHEET_PIN::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, @@ -76,7 +74,7 @@ void SCH_SHEET_PIN::Draw( WinEDA_DrawPanel* aPanel, { // The icon selection is handle by the virtual method CreateGraphicShape // called by ::Draw - SCH_HIERLABEL::Draw(aPanel, aDC, aOffset, aDraw_mode, aColor ); + SCH_HIERLABEL::Draw( aPanel, aDC, aOffset, aDraw_mode, aColor ); } @@ -99,10 +97,6 @@ bool SCH_SHEET_PIN::operator==( const SCH_SHEET_PIN* aPin ) const } -/** - * Function GetPenSize - * @return the size of the "pen" that be used to draw or plot this item - */ int SCH_SHEET_PIN::GetPenSize() const { return g_DrawDefaultLineThickness; @@ -124,6 +118,7 @@ void SCH_SHEET_PIN::SetEdge( int aEdge ) /* use -1 to adjust text orientation without changing edge*/ if( aEdge > -1 ) m_Edge = aEdge; + switch( m_Edge ) { case 0: /* pin on left side*/ @@ -155,10 +150,6 @@ int SCH_SHEET_PIN::GetEdge() } -/* ConstraintOnEdge is used to ajust label position to egde based - * on proximity to vertical / horizontal edge. - * used by sheetlab and resize - */ void SCH_SHEET_PIN::ConstraintOnEdge( wxPoint Pos ) { SCH_SHEET* Sheet = (SCH_SHEET*) GetParent(); @@ -195,26 +186,23 @@ void SCH_SHEET_PIN::ConstraintOnEdge( wxPoint Pos ) } m_Pos.x = Pos.x; + if( m_Pos.x < Sheet->m_Pos.x ) m_Pos.x = Sheet->m_Pos.x; + if( m_Pos.x > (Sheet->m_Pos.x + Sheet->m_Size.x) ) m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x; } } -/** - * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ bool SCH_SHEET_PIN::Save( FILE* aFile ) const { int type = 'U', side = 'L'; if( m_Text.IsEmpty() ) return true; + switch( m_Edge ) { case 0: //pin on left side @@ -331,14 +319,6 @@ bool SCH_SHEET_PIN::Load( LINE_READER& aLine, wxString& aErrorMsg ) } -/** - * Function Matches - * Compare hierarchical pin name against search string. - * @param aSearchData - Criteria to search against. - * @param aAuxData - a pointer on auxiliary data, not used here - * @param aFindLocation - a wxPoint where to put the location of matched item. can be NULL. - * @return True if this item matches the search criteria. - */ bool SCH_SHEET_PIN::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint * aFindLocation ) { @@ -346,6 +326,7 @@ bool SCH_SHEET_PIN::Matches( wxFindReplaceData& aSearchData, { if( aFindLocation ) *aFindLocation = m_Pos; + return true; } @@ -358,6 +339,7 @@ void SCH_SHEET_PIN::Mirror_X( int aXaxis_position ) int p = m_Pos.y - aXaxis_position; m_Pos.y = aXaxis_position - p; + switch( m_Edge ) { case 2: @@ -376,6 +358,7 @@ void SCH_SHEET_PIN::Mirror_Y( int aYaxis_position ) int p = m_Pos.x - aYaxis_position; m_Pos.x = aYaxis_position - p; + switch( m_Edge ) { case 0: @@ -392,6 +375,7 @@ void SCH_SHEET_PIN::Mirror_Y( int aYaxis_position ) void SCH_SHEET_PIN::Rotate( wxPoint rotationPoint ) { RotatePoint( &m_Pos, rotationPoint, 900 ); + switch( m_Edge ) { case 0: //pin on left side @@ -451,6 +435,7 @@ void SCH_SHEET_PIN::GetEndPoints( std::vector & aItemList ) #if defined(DEBUG) + void SCH_SHEET_PIN::Show( int nestLevel, std::ostream& os ) { // XML output: @@ -463,5 +448,4 @@ void SCH_SHEET_PIN::Show( int nestLevel, std::ostream& os ) // NestedSpace( nestLevel, os ) << "\n"; } - #endif diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index b98138804a..83201c7016 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -76,64 +76,42 @@ static int* TemplateShape[5][4] = SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) : - SCH_ITEM( NULL, aType ), EDA_TextStruct( text ) + SCH_ITEM( NULL, aType ), + EDA_TextStruct( text ) { m_Layer = LAYER_NOTES; - m_Pos = pos; + m_Pos = pos; m_Shape = 0; m_IsDangling = false; - m_MultilineAllowed = true; + m_MultilineAllowed = true; m_SchematicOrientation = 0; } -SCH_TEXT* SCH_TEXT::GenCopy() +SCH_TEXT::SCH_TEXT( const SCH_TEXT& aText ) : + SCH_ITEM( aText ), + EDA_TextStruct( aText ) { - SCH_TEXT* newitem; - - switch( Type() ) - { - default: - case SCH_TEXT_T: - newitem = new SCH_TEXT( m_Pos, m_Text ); - break; - - case SCH_GLOBAL_LABEL_T: - newitem = new SCH_GLOBALLABEL( m_Pos, m_Text ); - break; - - case SCH_HIERARCHICAL_LABEL_T: - newitem = new SCH_HIERLABEL( m_Pos, m_Text ); - break; - - case SCH_LABEL_T: - newitem = new SCH_LABEL( m_Pos, m_Text ); - break; - } - - newitem->m_Layer = m_Layer; - newitem->m_Shape = m_Shape; - newitem->m_Orient = m_Orient; - newitem->m_Size = m_Size; - newitem->m_Thickness = m_Thickness; - newitem->m_HJustify = m_HJustify; - newitem->m_VJustify = m_VJustify; - newitem->m_IsDangling = m_IsDangling; - newitem->m_Italic = m_Italic; - newitem->m_Bold = m_Bold; - newitem->m_SchematicOrientation = m_SchematicOrientation; - - return newitem; + m_Pos = aText.m_Pos; + m_Shape = aText.m_Shape; + m_MultilineAllowed = aText.m_MultilineAllowed; + m_SchematicOrientation = aText.m_SchematicOrientation; + m_IsDangling = false; +} + + +EDA_ITEM* SCH_TEXT::doClone() const +{ + return new SCH_TEXT( *this ); +} + + +void SCH_TEXT::IncrementLabel() +{ + IncrementLabelMember( m_Text ); } -/** - * Function GetSchematicTextOffset (virtual) - * @return the offset between the SCH_TEXT position and the text itself - * position - * This offset depend on orientation, and the type of text - * (room to draw an associated graphic symbol, or put the text above a wire) - */ wxPoint SCH_TEXT::GetSchematicTextOffset() { wxPoint text_offset; @@ -178,11 +156,6 @@ bool SCH_TEXT::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint } -/** - * Function Mirror_Y (virtual) - * mirror item relative to an Y axis - * @param aYaxis_position = the y axis position - */ void SCH_TEXT::Mirror_Y( int aYaxis_position ) { // Text is NOT really mirrored; it is moved to a suitable position @@ -224,11 +197,6 @@ void SCH_TEXT::Mirror_Y( int aYaxis_position ) } -/** - * Function Mirror_X (virtual) - * mirror item relative to an X axis - * @param aXaxis_position = the x axis position - */ void SCH_TEXT::Mirror_X( int aXaxis_position ) { // Text is NOT really mirrored; it is moved to a suitable position @@ -303,19 +271,6 @@ void SCH_TEXT::Rotate( wxPoint rotationPoint ) } -/** - * Function SetTextOrientAndJustifyParmeters (virtual) - * Set m_SchematicOrientation, and initialize - * m_orient,m_HJustified and m_VJustified, according to the value of - * m_SchematicOrientation - * must be called after changing m_SchematicOrientation - * @param aSchematicOrientation = - * 0 = normal (horizontal, left justified). - * 1 = up (vertical) - * 2 = (horizontal, right justified). This can be seen as the mirrored - * position of 0 - * 3 = bottom . This can be seen as the mirrored position of up - */ void SCH_TEXT::SetSchematicTextOrientation( int aSchematicOrientation ) { m_SchematicOrientation = aSchematicOrientation; @@ -388,10 +343,6 @@ void SCH_TEXT::Place( SCH_EDIT_FRAME* frame, wxDC* DC ) } -/** - * Function GetPenSize - * @return the size of the "pen" that be used to draw or plot this item - */ int SCH_TEXT::GetPenSize() const { int pensize = m_Thickness; @@ -410,9 +361,6 @@ int SCH_TEXT::GetPenSize() const } -/* Text type Comment (text on layer "NOTE") have 4 directions, and the Text - * origin is the first letter - */ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset, int DrawMode, int Color ) { @@ -425,6 +373,7 @@ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset, color = (EDA_Colors) Color; else color = ReturnLayerColor( m_Layer ); + GRSetDrawMode( DC, DrawMode ); wxPoint text_offset = aOffset + GetSchematicTextOffset(); @@ -671,7 +620,7 @@ EDA_Rect SCH_TEXT::GetBoundingBox() const } -bool SCH_TEXT::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const +bool SCH_TEXT::doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const { if( !( aFilter & TEXT_T ) ) return false; @@ -680,7 +629,7 @@ bool SCH_TEXT::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFi } -bool SCH_TEXT::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const +bool SCH_TEXT::doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const { return TextHitTest( aRect, aContained, aAccuracy ); } @@ -702,42 +651,9 @@ void SCH_TEXT::Show( int nestLevel, std::ostream& os ) << "\n"; } - #endif -/** - * Function GetSchematicTextOffset (virtual) - * @return the offset between the SCH_TEXT position and the text itself - * position - * This offset depend on orientation, and the type of text - * (room to draw an associated graphic symbol, or put the text above a wire) - */ -wxPoint SCH_LABEL::GetSchematicTextOffset() -{ - return SCH_TEXT::GetSchematicTextOffset(); -} - - -/** - * Function SetTextOrientAndJustifyParmeters - * Set m_SchematicOrientation, and initialize - * m_orient,m_HJustified and m_VJustified, according to the value of - * m_SchematicOrientation (for a label) - * must be called after changing m_SchematicOrientation - * @param aSchematicOrientation = - * 0 = normal (horizontal, left justified). - * 1 = up (vertical) - * 2 = (horizontal, right justified). This can be seen as the mirrored - * position of 0 - * 3 = bottom . This can be seen as the mirrored position of up - */ -void SCH_LABEL::SetSchematicTextOrientation( int aSchematicOrientation ) -{ - SCH_TEXT::SetSchematicTextOrientation( aSchematicOrientation ); -} - - SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) : SCH_TEXT( pos, text, SCH_LABEL_T ) { @@ -748,11 +664,30 @@ SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) : } -/** - * Function Mirror_X (virtual) - * mirror item relative to an X axis - * @param aXaxis_position = the x axis position - */ +SCH_LABEL::SCH_LABEL( const SCH_LABEL& aLabel ) : + SCH_TEXT( aLabel ) +{ +} + + +EDA_ITEM* SCH_LABEL::doClone() const +{ + return new SCH_LABEL( *this ); +} + + +wxPoint SCH_LABEL::GetSchematicTextOffset() +{ + return SCH_TEXT::GetSchematicTextOffset(); +} + + +void SCH_LABEL::SetSchematicTextOrientation( int aSchematicOrientation ) +{ + SCH_TEXT::SetSchematicTextOrientation( aSchematicOrientation ); +} + + void SCH_LABEL::Mirror_X( int aXaxis_position ) { // Text is NOT really mirrored; it is moved to a suitable position @@ -775,12 +710,6 @@ void SCH_LABEL::Rotate( wxPoint rotationPoint ) } -/** - * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ bool SCH_LABEL::Save( FILE* aFile ) const { bool success = true; @@ -862,10 +791,6 @@ bool SCH_LABEL::Load( LINE_READER& aLine, wxString& aErrorMsg ) } -/** - * Function Draw - * a label is drawn like a text. So just call SCH_TEXT::Draw - */ void SCH_LABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int DrawMode, int Color ) { @@ -921,7 +846,7 @@ EDA_Rect SCH_LABEL::GetBoundingBox() const } -bool SCH_LABEL::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const +bool SCH_LABEL::doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const { if( !( aFilter & LABEL_T ) ) return false; @@ -940,12 +865,18 @@ SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) : } -/** - * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ +SCH_GLOBALLABEL::SCH_GLOBALLABEL( const SCH_GLOBALLABEL& aGlobalLabel ) : + SCH_TEXT( aGlobalLabel ) +{ +} + + +EDA_ITEM* SCH_GLOBALLABEL::doClone() const +{ + return new SCH_GLOBALLABEL( *this ); +} + + bool SCH_GLOBALLABEL::Save( FILE* aFile ) const { bool success = true; @@ -953,6 +884,7 @@ bool SCH_GLOBALLABEL::Save( FILE* aFile ) const if( m_Italic ) shape = "Italic"; + if( fprintf( aFile, "Text GLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n", m_Pos.x, m_Pos.y, m_SchematicOrientation, m_Size.x, SheetLabelType[m_Shape], shape, m_Thickness, CONV_TO_UTF8( m_Text ) ) == EOF ) @@ -1016,12 +948,16 @@ bool SCH_GLOBALLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg ) if( stricmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 ) m_Shape = NET_OUTPUT; + if( stricmp( Name2, SheetLabelType[NET_BIDI] ) == 0 ) m_Shape = NET_BIDI; + if( stricmp( Name2, SheetLabelType[NET_TRISTATE] ) == 0 ) m_Shape = NET_TRISTATE; + if( stricmp( Name2, SheetLabelType[NET_UNSPECIFIED] ) == 0 ) m_Shape = NET_UNSPECIFIED; + if( stricmp( Name3, "Italic" ) == 0 ) m_Italic = 1; @@ -1029,11 +965,6 @@ bool SCH_GLOBALLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg ) } -/** - * Function Mirror_Y (virtual) - * mirror item relative to an Y axis - * @param aYaxis_position = the y axis position - */ void SCH_GLOBALLABEL::Mirror_Y( int aYaxis_position ) { /* The global label is NOT really mirrored. @@ -1084,13 +1015,6 @@ void SCH_GLOBALLABEL::Rotate( wxPoint rotationPoint ) } -/** - * Function GetSchematicTextOffset (virtual) - * @return the offset between the SCH_TEXT position and the text itself - * position - * This offset depend on orientation, and the type of text - * (room to draw an associated graphic symbol, or put the text above a wire) - */ wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset() { wxPoint text_offset; @@ -1140,19 +1064,6 @@ wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset() } -/** - * Function SetTextOrientAndJustifyParmeters - * Set m_SchematicOrientation, and initialize - * m_orient,m_HJustified and m_VJustified, according to the value of - * m_SchematicOrientation - * must be called after changing m_SchematicOrientation - * @param aSchematicOrientation = - * 0 = normal (horizontal, left justified). - * 1 = up (vertical) - * 2 = (horizontal, right justified). This can be seen as the mirrored - * position of 0 - * 3 = bottom . This can be seen as the mirrored position of up - */ void SCH_GLOBALLABEL::SetSchematicTextOrientation( int aSchematicOrientation ) { m_SchematicOrientation = aSchematicOrientation; @@ -1187,8 +1098,6 @@ void SCH_GLOBALLABEL::SetSchematicTextOrientation( int aSchematicOrientation ) } -/* Texts type Global Label have 4 directions, and the Text origin is the graphic icon - */ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset, @@ -1199,7 +1108,6 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, EDA_Colors color; wxPoint text_offset = aOffset + GetSchematicTextOffset(); - if( Color >= 0 ) color = (EDA_Colors) Color; else @@ -1229,12 +1137,6 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, } -/** - * Function CreateGraphicShape - * Calculates the graphic shape (a polygon) associated to the text - * @param aCorner_list = a buffer to fill with polygon corners coordinates - * @param Pos = Position of the shape - */ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector & aCorner_list, const wxPoint& Pos ) { @@ -1370,7 +1272,7 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox() const } -bool SCH_GLOBALLABEL::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const +bool SCH_GLOBALLABEL::doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const { if( !( aFilter & LABEL_T ) ) return false; @@ -1389,12 +1291,18 @@ SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T } -/** - * Function Save - * writes the data structures for this object out to a FILE in "*.brd" format. - * @param aFile The FILE to write to. - * @return bool - true if success writing else false. - */ +SCH_HIERLABEL::SCH_HIERLABEL( const SCH_HIERLABEL& aHierLabel ) : + SCH_TEXT( aHierLabel ) +{ +} + + +EDA_ITEM* SCH_HIERLABEL::doClone() const +{ + return new SCH_HIERLABEL( *this ); +} + + bool SCH_HIERLABEL::Save( FILE* aFile ) const { bool success = true; @@ -1402,6 +1310,7 @@ bool SCH_HIERLABEL::Save( FILE* aFile ) const if( m_Italic ) shape = "Italic"; + if( fprintf( aFile, "Text HLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n", m_Pos.x, m_Pos.y, m_SchematicOrientation, m_Size.x, SheetLabelType[m_Shape], shape, m_Thickness, CONV_TO_UTF8( m_Text ) ) == EOF ) @@ -1465,12 +1374,16 @@ bool SCH_HIERLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg ) if( stricmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 ) m_Shape = NET_OUTPUT; + if( stricmp( Name2, SheetLabelType[NET_BIDI] ) == 0 ) m_Shape = NET_BIDI; + if( stricmp( Name2, SheetLabelType[NET_TRISTATE] ) == 0 ) m_Shape = NET_TRISTATE; + if( stricmp( Name2, SheetLabelType[NET_UNSPECIFIED] ) == 0 ) m_Shape = NET_UNSPECIFIED; + if( stricmp( Name3, "Italic" ) == 0 ) m_Italic = 1; @@ -1478,19 +1391,6 @@ bool SCH_HIERLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg ) } -/** - * Function SetTextOrientAndJustifyParmeters - * Set m_SchematicOrientation, and initialize - * m_orient,m_HJustified and m_VJustified, according to the value of - * m_SchematicOrientation - * must be called after changing m_SchematicOrientation - * @param aSchematicOrientation = - * 0 = normal (horizontal, left justified). - * 1 = up (vertical) - * 2 = (horizontal, right justified). This can be seen as the mirrored - * position of 0 - * 3 = bottom . This can be seen as the mirrored position of up - */ void SCH_HIERLABEL::SetSchematicTextOrientation( int aSchematicOrientation ) { m_SchematicOrientation = aSchematicOrientation; @@ -1525,9 +1425,6 @@ void SCH_HIERLABEL::SetSchematicTextOrientation( int aSchematicOrientation ) } -/* Hierarchical Label have a text and a graphic icon. - * Texts type have 4 directions, and the text origin is the graphic icon - */ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, @@ -1568,12 +1465,6 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, } -/** - * Function CreateGraphicShape - * calculates the graphic shape (a polygon) associated to the text - * @param aCorner_list = a buffer to fill with polygon corners coordinates - * @param Pos = Postion of the shape - */ void SCH_HIERLABEL::CreateGraphicShape( std::vector & aCorner_list, const wxPoint& Pos ) { @@ -1583,6 +1474,7 @@ void SCH_HIERLABEL::CreateGraphicShape( std::vector & aCorner_list, int imax = *Template; Template++; aCorner_list.clear(); + for( int ii = 0; ii < imax; ii++ ) { wxPoint corner; @@ -1596,6 +1488,7 @@ void SCH_HIERLABEL::CreateGraphicShape( std::vector & aCorner_list, } } + EDA_Rect SCH_HIERLABEL::GetBoundingBox() const { int x, y, dx, dy, length, height; @@ -1648,13 +1541,6 @@ EDA_Rect SCH_HIERLABEL::GetBoundingBox() const } -/** - * Function GetSchematicTextOffset (virtual) - * @return the offset between the SCH_TEXT position and the text itself - * position - * This offset depend on orientation, and the type of text - * (room to draw an associated graphic symbol, or put the text above a wire) - */ wxPoint SCH_HIERLABEL::GetSchematicTextOffset() { wxPoint text_offset; @@ -1686,18 +1572,12 @@ wxPoint SCH_HIERLABEL::GetSchematicTextOffset() } -/** - * Function Mirror_Y (virtual) - * mirror item relative to an Y axis - * @param aYaxis_position = the y axis position - */ void SCH_HIERLABEL::Mirror_Y( int aYaxis_position ) { -/* The hierarchical label is NOT really mirrored. - * for an horizontal label, the schematic orientation is changed. - * for a vericalal label, the schematic orientation is not changed. - * and the label is moved to a suitable position - */ + /* The hierarchical label is NOT really mirrored for an horizontal label, the schematic + * orientation is changed. For a vericalal label, the schematic orientation is not changed + * and the label is moved to a suitable position. + */ switch( GetSchematicTextOrientation() ) { @@ -1705,7 +1585,7 @@ void SCH_HIERLABEL::Mirror_Y( int aYaxis_position ) SetSchematicTextOrientation( 2 ); break; - case 2: /* invert horizontal text*/ + case 2: /* invert horizontal text*/ SetSchematicTextOrientation( 0 ); break; } @@ -1742,7 +1622,7 @@ void SCH_HIERLABEL::Rotate( wxPoint rotationPoint ) } -bool SCH_HIERLABEL::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const +bool SCH_HIERLABEL::doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const { if( !( aFilter & LABEL_T ) ) return false; diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index b590617973..7a4be08a7e 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -56,6 +56,9 @@ public: SCH_TEXT( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString, KICAD_T aType = SCH_TEXT_T ); + + SCH_TEXT( const SCH_TEXT& aText ); + ~SCH_TEXT() { } virtual wxString GetClass() const @@ -63,6 +66,11 @@ public: return wxT( "SCH_TEXT" ); } + /** + * Function IncrementLabel + * increments the label text. + */ + void IncrementLabel(); /** * Function SetTextOrientAndJustifyParmeters @@ -161,15 +169,16 @@ public: m_Pos += aMoveVector; } - - /** virtual function Mirror_Y - * mirror item relative to an Y axis - * @param aYaxis_position = the y axis position + /** + * Function Mirror_Y + * mirrors the item relative to \a aYaxisPosition. + * @param aYaxis_position The y axis coordinate to mirror around. */ - virtual void Rotate( wxPoint rotationPoint ); virtual void Mirror_Y( int aYaxis_position ); - virtual void Mirror_X( int aXaxis_position ); + virtual void Rotate( wxPoint rotationPoint ); + + virtual void Mirror_X( int aXaxis_position ); /** * Compare schematic text entry against search string. @@ -196,8 +205,9 @@ public: #endif private: - virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; - virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const; + virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; + virtual bool doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const; + virtual EDA_ITEM* doClone() const; }; @@ -205,6 +215,9 @@ class SCH_LABEL : public SCH_TEXT { public: SCH_LABEL( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString ); + + SCH_LABEL( const SCH_LABEL& aLabel ); + ~SCH_LABEL() { } virtual void Draw( WinEDA_DrawPanel* panel, @@ -218,7 +231,6 @@ public: return wxT( "SCH_LABEL" ); } - /** * Function SetTextOrientAndJustifyParmeters * Set m_SchematicOrientation, and initialize @@ -243,7 +255,9 @@ public: * wire) */ virtual wxPoint GetSchematicTextOffset(); + virtual void Mirror_X( int aXaxis_position ); + virtual void Rotate( wxPoint rotationPoint ); /** @@ -275,7 +289,8 @@ public: virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ); private: - virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; + virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; + virtual EDA_ITEM* doClone() const; }; @@ -283,6 +298,9 @@ class SCH_GLOBALLABEL : public SCH_TEXT { public: SCH_GLOBALLABEL( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString ); + + SCH_GLOBALLABEL( const SCH_GLOBALLABEL& aGlobalLabel ); + ~SCH_GLOBALLABEL() { } virtual void Draw( WinEDA_DrawPanel* panel, @@ -296,7 +314,6 @@ public: return wxT( "SCH_GLOBALLABEL" ); } - /** * Function SetTextOrientAndJustifyParmeters * Set m_SchematicOrientation, and initialize @@ -356,8 +373,7 @@ public: * @param aCorner_list = a buffer to fill with polygon corners coordinates * @param aPos = Position of the shape */ - virtual void CreateGraphicShape( std::vector & aCorner_list, - const wxPoint& aPos ); + virtual void CreateGraphicShape( std::vector & aCorner_list, const wxPoint& aPos ); /** virtual function Mirror_Y * mirror item relative to an Y axis @@ -370,7 +386,8 @@ public: virtual void Rotate( wxPoint rotationPoint ); private: - virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; + virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; + virtual EDA_ITEM* doClone() const; }; @@ -381,7 +398,10 @@ public: const wxString& text = wxEmptyString, KICAD_T aType = SCH_HIERARCHICAL_LABEL_T ); + SCH_HIERLABEL( const SCH_HIERLABEL& aHierLabel ); + ~SCH_HIERLABEL() { } + virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, @@ -393,7 +413,6 @@ public: return wxT( "SCH_HIERLABEL" ); } - /** * Function SetTextOrientAndJustifyParmeters * Set m_SchematicOrientation, and initialize @@ -425,8 +444,7 @@ public: * @param aCorner_list = a buffer to fill with polygon corners coordinates * @param Pos = Postion of the shape */ - virtual void CreateGraphicShape( std::vector & aCorner_list, - const wxPoint& Pos ); + virtual void CreateGraphicShape( std::vector & aCorner_list, const wxPoint& Pos ); /** * Function Save @@ -467,7 +485,8 @@ public: virtual void Rotate( wxPoint rotationPoint ); private: - virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; + virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const; + virtual EDA_ITEM* doClone() const; }; #endif /* CLASS_TEXT_LABEL_H */ diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 5502b1be52..a024327ea2 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -17,9 +17,11 @@ #include "eeschema_id.h" #include "protos.h" #include "class_library.h" +#include "sch_bus_entry.h" #include "sch_marker.h" #include "sch_component.h" #include "sch_items.h" +#include "sch_line.h" #include "sch_sheet.h" @@ -454,7 +456,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_SCH_DRAG_WIRE_REQUEST: DrawPanel->MouseToCursorSchema(); - // The easiest way to handle a drag component is to simulate a // block drag command if( screen->m_BlockLocate.m_State == STATE_NO_BLOCK ) @@ -472,13 +473,12 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) // TODO: a better way to drag only wires SCH_LINE* segm = (SCH_LINE*) screen->GetCurItem(); - if( !screen->m_BlockLocate.Inside( segm->m_Start ) - && !screen->m_BlockLocate.Inside( segm->m_End ) ) + if( !screen->m_BlockLocate.Contains( segm->m_Start ) + && !screen->m_BlockLocate.Contains( segm->m_End ) ) { screen->m_BlockLocate.SetOrigin( segm->m_Start ); screen->m_BlockLocate.SetEnd( segm->m_End ); } - HandleBlockEnd( &dc ); } break; diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp index 2be9d495bf..07cd4547e3 100644 --- a/eeschema/schematic_undo_redo.cpp +++ b/eeschema/schematic_undo_redo.cpp @@ -10,9 +10,13 @@ #include "general.h" #include "protos.h" +#include "sch_bus_entry.h" #include "sch_marker.h" #include "sch_items.h" +#include "sch_line.h" +#include "sch_no_connect.h" #include "sch_component.h" +#include "sch_polyline.h" #include "sch_sheet.h" diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp index f6311205dc..f34f97c5ae 100644 --- a/eeschema/symbdraw.cpp +++ b/eeschema/symbdraw.cpp @@ -242,7 +242,16 @@ static void RedrawWhileMovingCursor( WinEDA_DrawPanel* panel, wxDC* DC, bool era BASE_SCREEN* Screen = panel->GetScreen(); item->SetEraseLastDrawItem( erase ); - item->Draw( panel, DC, Screen->GetCursorDrawPosition(), -1, g_XorMode, NULL, + // if item is the reference field, we must add the current unit id + if( item->Type() == LIB_FIELD_T ) + { + int unit = ((LIB_EDIT_FRAME*)panel->GetParent())->GetUnit(); + wxString text = ((LIB_FIELD*)item)->GetFullText( unit ); + item->Draw( panel, DC, Screen->GetCursorDrawPosition(), -1, g_XorMode, &text, + DefaultTransform ); + } + else + item->Draw( panel, DC, Screen->GetCursorDrawPosition(), -1, g_XorMode, NULL, DefaultTransform ); } @@ -254,9 +263,6 @@ void LIB_EDIT_FRAME::StartMoveDrawSymbol( wxDC* DC ) SetCursor( wxCURSOR_HAND ); - if( m_drawItem->GetUnit() != m_unit ) - m_drawItem->SetUnit( m_unit ); - TempCopyComponent(); m_drawItem->BeginEdit( IS_MOVED, GetScreen()->GetCursorDrawPosition() ); DrawPanel->ManageCurseur = RedrawWhileMovingCursor; diff --git a/gerbview/class_gerber_draw_item.cpp b/gerbview/class_gerber_draw_item.cpp index 4424c39c34..0274c701cd 100644 --- a/gerbview/class_gerber_draw_item.cpp +++ b/gerbview/class_gerber_draw_item.cpp @@ -668,10 +668,10 @@ bool GERBER_DRAW_ITEM::HitTest( EDA_Rect& aRefArea ) { wxPoint pos = GetABPosition( m_Start ); - if( aRefArea.Inside( pos ) ) + if( aRefArea.Contains( pos ) ) return true; pos = GetABPosition( m_End ); - if( aRefArea.Inside( pos ) ) + if( aRefArea.Contains( pos ) ) return true; return false; } diff --git a/gerbview/dialogs/dialog_gerber_config.cpp b/gerbview/dialogs/dialog_gerber_config.cpp index 7937cf7d5e..87b0315f9a 100644 --- a/gerbview/dialogs/dialog_gerber_config.cpp +++ b/gerbview/dialogs/dialog_gerber_config.cpp @@ -124,7 +124,7 @@ WinEDA_ConfigFrame::WinEDA_ConfigFrame( WinEDA_GerberFrame* parent, } -void WinEDA_ConfigFrame::OnOkClick( wxCommandEvent &event ) +void WinEDA_ConfigFrame::OnOkClick( wxCommandEvent& event ) { g_DrillFilenameExt = TextDrillExt->GetValue(); g_PhotoFilenameExt = TextPhotoExt->GetValue(); @@ -134,7 +134,7 @@ void WinEDA_ConfigFrame::OnOkClick( wxCommandEvent &event ) } -void WinEDA_ConfigFrame::OnCancelClick( wxCommandEvent &event ) +void WinEDA_ConfigFrame::OnCancelClick( wxCommandEvent& event ) { EndModal( -1 ); } diff --git a/include/appl_wxstruct.h b/include/appl_wxstruct.h index 0147d883ef..47ad521a94 100644 --- a/include/appl_wxstruct.h +++ b/include/appl_wxstruct.h @@ -76,11 +76,23 @@ protected: public: WinEDA_App(); ~WinEDA_App(); + + /** + * Function OnInit + * this is the first executed function (like main() ) + * @return true if the appliction can be started. + */ bool OnInit(); bool SetBinDir(); void SetDefaultSearchPaths( void ); + /** + * Function MacOpenFile + * Specific to MacOSX. Not used under Linux or Windows + * MacOSX: Needed for file association + * http://wiki.wxwidgets.org/WxMac-specific_topics + */ virtual void MacOpenFile(const wxString &fileName); /** diff --git a/include/base_struct.h b/include/base_struct.h index 88321c38dd..bcd64fb119 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -7,14 +7,16 @@ #include "colors.h" +#include + #if defined(DEBUG) #include // needed for Show() extern std::ostream& operator <<( std::ostream& out, const wxSize& size ); extern std::ostream& operator <<( std::ostream& out, const wxPoint& pt ); - #endif + /* Id for class identification, at run time */ enum KICAD_T { NOT_USED = -1, // the 3d code uses this value @@ -146,7 +148,9 @@ public: * Class EDA_Rect * handles the component boundary box. * This class is similar to wxRect, but some wxRect functions are very curious, - * so I prefer this suitable class + * and are working only if dimensions are >= 0 (not always the case in kicad) + * and also kicad needs some specific method. + * so I prefer this more suitable class */ class EDA_Rect { @@ -168,16 +172,40 @@ public: m_Pos.y + ( m_Size.y >> 1 ) ); } - - /* Move this by the aMoveVector value (this is a relative move + /** + * Function Move + * moves the rectangle by the \a aMoveVector. + * @param aMoveVector A wxPoint that is the value to move this rectangle */ void Move( const wxPoint& aMoveVector ); - void Normalize(); // Ensure the height and width are >= 0 - bool Inside( const wxPoint& point ) const; // Return TRUE if point is in Rect + /** + * Function Normalize + * ensures thatthe height ant width are positive. + */ + void Normalize(); + + /** + * Function Contains + * @param aPoint = the wxPoint to test + * @return true if aPoint is inside the boundary box. A point on a edge is seen as inside + */ + bool Contains( const wxPoint& aPoint ) const; + /** + * Function Contains + * @param x = the x coordinate of the point to test + * @param y = the x coordinate of the point to test + * @return true if point is inside the boundary box. A point on a edge is seen as inside + */ + bool Contains( int x, int y ) const { return Contains( wxPoint( x, y ) ); } + + /** + * Function Contains + * @param aRect = the EDA_Rect to test + * @return true if aRect is Contained. A common edge is seen as contained + */ + bool Contains( const EDA_Rect& aRect ) const; - bool Inside( int x, int y ) const { return Inside( wxPoint( x, y ) ); } - bool Inside( const EDA_Rect& aRect ) const; wxSize GetSize() const { return m_Size; } int GetX() const { return m_Pos.x; } int GetY() const { return m_Pos.y; } @@ -209,9 +237,9 @@ public: /** * Function Intersects * @return bool - true if the argument rectangle intersects this rectangle. + * (i.e. if the 2 rectangles have at least a common point) */ - bool Intersects( const EDA_Rect aRect ) const; - + bool Intersects( const EDA_Rect& aRect ) const; /** * Function operator(wxRect) @@ -219,35 +247,32 @@ public: */ operator wxRect() const { return wxRect( m_Pos, m_Size ); } - /** Inflate - * Inflate this object: move each horizontal edge by dx and each vertical - * edge by dy toward rect outside - * if dx and/or dy is negative, move toward rect inside (deflate) - * Works for positive and negative rect size + /** + * Function Inflate + * inflates the rectangle horizontally by \a dx and vertically by \a dy. If \a dx + * and/or \a dy is negative the rectangle is deflated. */ EDA_Rect& Inflate( wxCoord dx, wxCoord dy ); - /** Inflate - * Inflate this object: move each horizontal edge and each vertical edge by - * aDelta toward rect outside - * if aDelta is negative, move toward rect inside (deflate) - * Works for positive and negative rect size + /** + * Function Inflate + * inflates the rectangle horizontally and vertically by \a aDelta. If \a aDelta + * is negative the rectangle is deflated. */ EDA_Rect& Inflate( int aDelta ); /** * Function Merge - * Modify Position and Size of this in order to contain the given rect - * mainly used to calculate bounding boxes - * @param aRect = given rect to merge with this + * modifies the position and size of the rectangle in order to contain \a aRect. It is + * mainly used to calculate bounding boxes. + * @param aRect The rectangle to merge with this rectangle. */ void Merge( const EDA_Rect& aRect ); /** * Function Merge - * Modify Position and Size of this in order to contain the given point - * mainly used to calculate bounding boxes - * @param aPoint = given point to merge with this + * modifies the position and size of the rectangle in order to contain the given point. + * @param aPoint The point to merge with the rectangle. */ void Merge( const wxPoint& aPoint ); }; @@ -319,6 +344,21 @@ public: private: void InitVars(); + /** + * @brief Function doClone + * is used by the derived class to actually implement the cloning. + * + * The default version will return NULL in release builds and likely crash the + * program. In debug builds, an warning message indicating the derived class + * has not implemented cloning. This really should be a pure virtual function. + * Due to the fact that there are so many objects derived from EDA_ITEM, the + * decision was made to return NULL until all the objects derived from EDA_ITEM + * implement cloning. Once that happens, this function should be made pure. + * + * @return A clone of the item. + */ + virtual EDA_ITEM* doClone() const; + public: EDA_ITEM( EDA_ITEM* parent, KICAD_T idType ); @@ -392,7 +432,6 @@ public: // derived classes may implement this } - /** * Function HitTest * tests if the given wxPoint is within the bounds of this object. @@ -404,7 +443,6 @@ public: return false; // derived classes should override this function } - /** * Function HitTest (overlaid) * tests if the given EDA_Rect intersect this object. @@ -417,7 +455,6 @@ public: return false; // derived classes should override this function } - /** * Function GetBoundingBox * returns the orthogonal, bounding box of this object for display @@ -439,6 +476,16 @@ public: return EDA_Rect( wxPoint( 0, 0 ), wxSize( 0, 0 ) ); } + /** + * @brief Function Clone + * creates a duplicate of this item with linked list members set to NULL. + * + * The Clone() function only calls the private virtual doClone() which actually + * does the cloning for the derived object. + * + * @return A clone of the item. + */ + EDA_ITEM* Clone() const { return doClone(); } /** * Function IterateForward @@ -517,6 +564,25 @@ public: }; +/** + * Function new_clone + * provides cloning capabilities for all Boost pointer containers of EDA_ITEMs. + * + * @param aItem EDA_ITEM to clone. + * @return Clone of \a aItem. + */ +inline EDA_ITEM* new_clone( const EDA_ITEM& aItem ) { return aItem.Clone(); } + + +/** + * Define list of drawing items for screens. + * + * The Boost containter was choosen over the statand C++ contain because you can detach + * the pointer from a list with the release method. + */ +typedef boost::ptr_vector< EDA_ITEM > EDA_ITEMS; + + // Graphic Text justify: // Values -1,0,1 are used in computations, do not change them enum GRTextHorizJustifyType { @@ -586,6 +652,7 @@ public: public: EDA_TextStruct( const wxString& text = wxEmptyString ); + EDA_TextStruct( const EDA_TextStruct& aText ); virtual ~EDA_TextStruct(); int GetLength() const { return m_Text.Length(); }; diff --git a/include/class_base_screen.h b/include/class_base_screen.h index 1a260a0372..80bf0ecad5 100644 --- a/include/class_base_screen.h +++ b/include/class_base_screen.h @@ -14,22 +14,11 @@ #include "block_commande.h" #include "common.h" -#include - // Forward declarations: class Ki_PageDescr; -/** - * Define list of drawing items for screens. - * - * The Boost containter was choosen over the statand C++ contain because you can detach - * the pointer from a list with the release method. - */ -typedef boost::ptr_vector< EDA_ITEM > EDA_ITEMS; - - /* Simple class for handling grid arrays. */ class GRID_TYPE { diff --git a/include/class_marker_base.h b/include/class_marker_base.h index 9033a20f6e..b8686b4d57 100644 --- a/include/class_marker_base.h +++ b/include/class_marker_base.h @@ -10,13 +10,16 @@ class MARKER_BASE { public: - wxPoint m_Pos; ///< position of the marker + wxPoint m_Pos; ///< position of the marker protected: - std::vector m_Corners; ///< Corner list for shape definition (a polygon) - int m_MarkerType; ///< Can be used as a flag - EDA_Colors m_Color; ///< color - EDA_Rect m_ShapeBoundingBox; ///< Bounding box of the graphic symbol, relative to the position of the shape, used for Hit Tests - int m_ScalingFactor; ///< Scaling factor for m_Size and m_Corners (can set the physical size + std::vector m_Corners; ///< Corner list for shape definition (a polygon) + int m_MarkerType; ///< Can be used as a flag + EDA_Colors m_Color; ///< color + EDA_Rect m_ShapeBoundingBox; ///< Bounding box of the graphic symbol, relative + ///< to the position of the shape, used for Hit + ///< Tests + int m_ScalingFactor; ///< Scaling factor for m_Size and m_Corners (can + ///< set the physical size DRC_ITEM m_drc; void init(); @@ -48,14 +51,21 @@ public: MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos, const wxString& aText, const wxPoint& aPos ); + /** + * Contructor + * makes a copy of \a aMarker but does not copy the DRC_ITEM. + * + * @param aMarker The marker to copy. + */ + MARKER_BASE( const MARKER_BASE& aMarker ); ~MARKER_BASE(); /** * Function DrawMarker + * draws the shape is the polygon defined in m_Corners (array of wxPoints). */ - void DrawMarker( WinEDA_DrawPanel* panel, wxDC* DC, int DrawMode, const wxPoint& offset ); - + void DrawMarker( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode, const wxPoint& aOffset ); /** * Function GetPos @@ -66,7 +76,6 @@ public: return m_Pos; } - /** * Function SetColor * Set the color of this marker @@ -76,7 +85,6 @@ public: m_Color = aColor; } - /** * Function to set/get error levels (warning, fatal ..) * this value is stored in m_MarkerType @@ -88,13 +96,11 @@ public: m_MarkerType |= aErrorLevel << 8; } - int GetErrorLevel() const { return (m_MarkerType >> 8) & 0xFF; } - /** Functions to set/get marker type (DRC, ERC, or other) * this value is stored in m_MarkerType */ @@ -105,13 +111,11 @@ public: m_MarkerType |= aMarkerType; } - int GetMarkerType() const { return m_MarkerType & 0xFF; } - /** * Function SetData * fills in all the reportable data associated with a MARKER. @@ -137,11 +141,11 @@ public: void SetData( int aErrorCode, const wxPoint& aMarkerPos, const wxString& aText, const wxPoint& aPos ); - /** * Function SetAuxiliaryData * initialize data for the second (auxiliary) item - * @param aAuxiliaryText = the second text (main text) concerning the second schematic or board item + * @param aAuxiliaryText = the second text (main text) concerning the second schematic or + * board item * @param aAuxiliaryPos = position the second item */ void SetAuxiliaryData( const wxString& aAuxiliaryText, const wxPoint& aAuxiliaryPos ) @@ -165,12 +169,11 @@ public: return m_drc; } - /** * Function DisplayMarkerInfo - * Displays the full info of this marker, in a HTML window + * displays the full info of this marker, in a HTML window. */ - void DisplayMarkerInfo(WinEDA_DrawFrame * aFrame); + void DisplayMarkerInfo( WinEDA_DrawFrame* aFrame ); /** * Function HitTestMarker diff --git a/include/hotkeys_basic.h b/include/hotkeys_basic.h index a2b3cb617d..a54cffaa5a 100644 --- a/include/hotkeys_basic.h +++ b/include/hotkeys_basic.h @@ -137,17 +137,18 @@ void DisplayHotkeyList( WinEDA_DrawFrame* aFrame */ Ki_HotkeyInfo* GetDescriptorFromHotkey( int aKey, Ki_HotkeyInfo** aList ); -/** function ReadHotkeyConfig * Read hotkey configuration for a given - app, possibly before the frame for that app has been created - - @param Appname = the value of the app's m_FrameName - @param DescList = the hotkey data +/** + * Function ReadHotkeyConfig + * Read hotkey configuration for a given app, + * possibly before the frame for that app has been created + * @param Appname = the value of the app's m_FrameName + * @param aDescList = the hotkey data */ - void ReadHotkeyConfig( const wxString& Appname, - struct Ki_HotkeyInfoSectionDescriptor* DescList ); + struct Ki_HotkeyInfoSectionDescriptor* aDescList ); + void ParseHotkeyConfig( const wxString& data, - struct Ki_HotkeyInfoSectionDescriptor* DescList ); + struct Ki_HotkeyInfoSectionDescriptor* aDescList ); // common hotkeys event id diff --git a/include/sch_item_struct.h b/include/sch_item_struct.h index c60a64e8ec..54272c232d 100644 --- a/include/sch_item_struct.h +++ b/include/sch_item_struct.h @@ -39,6 +39,16 @@ enum SCH_FILTER_T { }; +/* used to calculate the pen size from default value + * the actual pen size is default value * BUS_WIDTH_EXPAND + */ +#if defined(KICAD_GOST) +#define BUS_WIDTH_EXPAND 3.6 +#else +#define BUS_WIDTH_EXPAND 1.4 +#endif + + enum DANGLING_END_T { UNKNOWN = 0, WIRE_START_END, @@ -84,6 +94,8 @@ protected: public: SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType ); + SCH_ITEM( const SCH_ITEM& aItem ); + ~SCH_ITEM(); virtual wxString GetClass() const @@ -91,6 +103,8 @@ public: return wxT( "SCH_ITEM" ); } + SCH_ITEM* Clone() const { return ( SCH_ITEM* ) EDA_ITEM::Clone(); } + SCH_ITEM* Next() { return (SCH_ITEM*) Pnext; } SCH_ITEM* Back() { return (SCH_ITEM*) Pback; } @@ -122,37 +136,38 @@ public: int aDrawMode, int aColor = -1 ) = 0; - /* Place function */ virtual void Place( SCH_EDIT_FRAME* aFrame, wxDC* aDC ); - // Geometric transforms (used in block operations): - /** virtual function Move - * move item to a new position. + /** + * Function Move + * moves the item by \a aMoveVector to a new position. * @param aMoveVector = the deplacement vector */ virtual void Move( const wxPoint& aMoveVector ) = 0; - /** virtual function Mirror_Y - * mirror item relative to an Y axis - * @param aYaxis_position = the y axis position + /** + * Function Mirror_Y + * mirrors item relative to an Y axis about \a aYaxis_position. + * @param aYaxis_position The Y axis position to mirror around. */ virtual void Mirror_Y( int aYaxis_position ) = 0; - virtual void Mirror_X( int aXaxis_position ) = 0; - virtual void Rotate( wxPoint rotationPoint ) = 0; + virtual void Mirror_X( int aXaxis_position ) = 0; + + virtual void Rotate( wxPoint rotationPoint ) = 0; /** * Function Save - * writes the data structures for this object out to a FILE in "*.sch" - * format. + * writes the data structures for this object out to a FILE in "*.sch" format. * @param aFile The FILE to write to. * @return bool - true if success writing else false. */ virtual bool Save( FILE* aFile ) const = 0; /** - * Load schematic item from \a aLine in a .sch file. + * Function Load + * reads a schematic item from \a aLine in a .sch file. * * @param aLine - Essentially this is file to read the object from. * @param aErrorMsg - Description of the error if an error occurs while loading the object. @@ -161,7 +176,8 @@ public: virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ) { return false; } /** - * Compare schematic item against search string. + * Function Matches + * compares the schematic item against search \a aSearchData. * * The base class returns false since many of the objects derived from * SCH_ITEM do not have any text to search. @@ -190,7 +206,8 @@ public: bool Matches( const wxString& aText, wxFindReplaceData& aSearchData ); /** - * Add schematic item end points to \a aItemList if the item has endpoints. + * Function GetEndPoints + * adds the schematic item end points to \a aItemList if the item has end points. * * The default version doesn't do anything since many of the schematic object cannot * be tested for dangling ends. If you add a new schematic item that can have a @@ -202,7 +219,8 @@ public: virtual void GetEndPoints( vector< DANGLING_END_ITEM >& aItemList ) {} /** - * Test the schematic item to \a aItemList to check if it's dangling state has changed. + * Function IsDanglingStateChanged + * tests the schematic item to \a aItemList to check if it's dangling state has changed. * * Note that the return value only true when the state of the test has changed. Use * the IsDangling() method to get the current dangling state of the item. Some of @@ -218,9 +236,10 @@ public: virtual bool IsDangling() const { return false; } /** - * Check if the selection state of an item inside \a aRect has changed. + * Function IsSelectStateChanged + * checks if the selection state of an item inside \a aRect has changed. * - * The is used by the block selection code to verify if an item is selected or not. + * This is used by the block selection code to verify if an item is selected or not. * True is be return anytime the select state changes. If you need to know the * the current selection state, use the IsSelected() method. * @@ -229,16 +248,18 @@ public: virtual bool IsSelectStateChanged( const wxRect& aRect ) { return false; } /** - * Get a list of connection points for this item. + * Function GetConnectionPoints + * add all the connection points for this item to \a aPoints. * * Not all schematic items have connection points so the default method does nothing. * - * @param aPoints - List of connection points to add to. + * @param aPoints List of connection points to add to. */ virtual void GetConnectionPoints( vector< wxPoint >& aPoints ) const { } /** - * Clear all of the connection items from the list. + * Function ClearConnections + * clears all of the connection items from the list. * * The vector release method is used to prevent the item pointers from being deleted. * Do not use the vector erase method on the connection list. @@ -246,8 +267,8 @@ public: void ClearConnections() { m_connections.release(); } /** - * Function IsConnected(). - * Test \a aPoint to see if it is connected to this schematic object. + * Function IsConnected + * tests the item to see if it is connected to \a aPoint. * * @param aPoint - Position to test for connection. * @return True if connection to \a aPoint exists. @@ -255,8 +276,8 @@ public: bool IsConnected( const wxPoint& aPoint ) const; /** - * Function HitTest(). - * Test if \a aPoint is contained within the bounding box or on an item. + * Function HitTest + * tests if \a aPoint is contained within or on the bounding box of an item. * * @param aPoint - Point to test. * @param aAccuracy - Increase the item bounding box by this amount. @@ -266,21 +287,21 @@ public: bool HitTest( const wxPoint& aPoint, int aAccuracy = 0, SCH_FILTER_T aFilter = NO_FILTER_T ) const { - return DoHitTest( aPoint, aAccuracy, aFilter ); + return doHitTest( aPoint, aAccuracy, aFilter ); } /** - * Function HitTest(). - * Test if \a aRect intersects or is contained within the bounding box of an item. + * Function HitTest + * tests if \a aRect intersects or is contained within the bounding box of an item. * * @param aRect - Rectangle to test. * @param aContained - Set to true to test for containment instead of an intersection. - * @param aAccuracy - Increase the item bounding box by this amount. + * @param aAccuracy - Increase aRect by this amount. * @return True if \a aRect contains or intersects the item bounding box. */ bool HitTest( const EDA_Rect& aRect, bool aContained = false, int aAccuracy = 0 ) const { - return DoHitTest( aRect, aContained, aAccuracy ); + return doHitTest( aRect, aContained, aAccuracy ); } /** @@ -290,17 +311,17 @@ public: * http://www.gotw.ca/publications/mill18.htm. */ private: - virtual bool DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const + virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const { return false; } - virtual bool DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const + virtual bool doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const { return false; } - virtual bool DoIsConnected( const wxPoint& aPosition ) const { return false; } + virtual bool doIsConnected( const wxPoint& aPosition ) const { return false; } }; #endif /* SCH_ITEM_STRUCT_H */ diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index 686dd8721e..cb028a41fe 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -139,7 +139,7 @@ public: ~WinEDA_PcbFrame(); - void OnQuit( wxCommandEvent & WXUNUSED(event) ); + void OnQuit( wxCommandEvent& event ); /** * Function ToPlotter @@ -480,7 +480,7 @@ public: * @param aKey = the key modifiers (Alt, Shift ...) * @return the block command id (BLOCK_MOVE, BLOCK_COPY...) */ - virtual int ReturnBlockCommand( int key ); + virtual int ReturnBlockCommand( int aKey ); /** * Function HandleBlockPlace( ) @@ -805,18 +805,19 @@ public: * Modify a full track width (using DRC control). * a full track is the set of track segments between 2 ends: pads or a * point that has more than 2 segments ends connected - * @param DC = the curred device context (can be NULL) + * @param aDC = the curred device context (can be NULL) * @param aTrackSegment = a segment or via on the track to change */ - void Edit_Track_Width( wxDC* DC, TRACK* Track ); + void Edit_Track_Width( wxDC* aDC, TRACK* aTrackSegment ); /** * Function Edit_TrackSegm_Width * Modify one track segment width or one via diameter (using DRC control). - * @param DC = the current device context (can be NULL) + * @param aDC = the current device context (can be NULL) * @param aTrackItem = the track segment or via to modify */ - void Edit_TrackSegm_Width( wxDC* DC, TRACK* segm ); + void Edit_TrackSegm_Width( wxDC* aDC, TRACK* aTrackItem ); + TRACK* Begin_Route( TRACK* track, wxDC* DC ); void End_Route( TRACK* track, wxDC* DC ); void ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC ); @@ -868,7 +869,7 @@ public: // zone handling /** - * Function Delete_Zone_Fill + * Function Delete_Zone_Fill (obsolete) * Remove the zone filling which include the segment aZone, or the zone * which have the given time stamp. A zone is a group of segments which * have the same TimeStamp @@ -876,7 +877,7 @@ public: * @param aTimestamp = Timestamp for the zone to delete, used if aZone == * NULL */ - void Delete_Zone_Fill( SEGZONE* Track, long aTimestamp = 0 ); + void Delete_Zone_Fill( SEGZONE* aZone, long aTimestamp = 0 ); /** @@ -1033,6 +1034,13 @@ public: * @param aNetlistFullFilename = netlist file name (*.net) * @param aCmpFullFileName = cmp/footprint list file name (*.cmp) if not found, * only the netlist will be used + * @param aMessageWindow = a reference to a wxTextCtrl where to dislay messages. + * can be NULL + * @param aChangeFootprint if true, footprints that have changed in netlist will be changed + * @param aDeleteBadTracks if true, erroneous tracks will be deleted + * @param aDeleteExtraFootprints if true, remove unlocked footprints that are not in netlist + * @param aSelect_By_Timestamp if true, use timestamp instead of reference to identify footprints + * from components (use after reannotation of the chematic) * @return true if Ok * * the format of the netlist is something like: diff --git a/packaging/windows/nsis/install.nsi b/packaging/windows/nsis/install.nsi index 5719b2ea56..b86e7d3270 100644 --- a/packaging/windows/nsis/install.nsi +++ b/packaging/windows/nsis/install.nsi @@ -17,7 +17,7 @@ ; General Product Description Definitions !define PRODUCT_NAME "KiCad" -!define PRODUCT_VERSION "2010.12.18" +!define PRODUCT_VERSION "2010.12.22" !define PRODUCT_WEB_SITE "http://iut-tice.ujf-grenoble.fr/kicad/" !define SOURCEFORGE_WEB_SITE "http://kicad.sourceforge.net/" !define COMPANY_NAME "" diff --git a/pcbnew/automove.cpp b/pcbnew/automove.cpp index d8ac334327..4481d7944f 100644 --- a/pcbnew/automove.cpp +++ b/pcbnew/automove.cpp @@ -224,7 +224,7 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) Module = moduleList[ii]; if( PlaceModulesHorsPcb && edgesExists ) { - if( GetBoard()->m_BoundaryBox.Inside( Module->m_Pos ) ) + if( GetBoard()->m_BoundaryBox.Contains( Module->m_Pos ) ) continue; } surface += Module->m_Surface; @@ -243,7 +243,7 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) if( PlaceModulesHorsPcb && edgesExists ) { - if( GetBoard()->m_BoundaryBox.Inside( Module->m_Pos ) ) + if( GetBoard()->m_BoundaryBox.Contains( Module->m_Pos ) ) continue; } diff --git a/pcbnew/autoplac.cpp b/pcbnew/autoplac.cpp index 6d6a602ce4..a5e835b564 100644 --- a/pcbnew/autoplac.cpp +++ b/pcbnew/autoplac.cpp @@ -150,7 +150,7 @@ void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module, Module->m_ModuleStatus &= ~MODULE_is_PLACED; if( Module->m_ModuleStatus & MODULE_is_LOCKED ) break; - if( !GetBoard()->m_BoundaryBox.Inside( Module->m_Pos ) ) + if( !GetBoard()->m_BoundaryBox.Contains( Module->m_Pos ) ) Module->m_ModuleStatus |= MODULE_to_PLACE; break; diff --git a/pcbnew/block_module_editor.cpp b/pcbnew/block_module_editor.cpp index 50a9b5a5a2..f34f3b59d2 100644 --- a/pcbnew/block_module_editor.cpp +++ b/pcbnew/block_module_editor.cpp @@ -657,7 +657,7 @@ int MarkItemsInBloc( MODULE* module, EDA_Rect& Rect ) { pad->m_Selected = 0; pos = pad->GetPosition(); - if( Rect.Inside( pos ) ) + if( Rect.Contains( pos ) ) { pad->m_Selected = IS_SELECTED; ItemsCount++; @@ -673,13 +673,13 @@ int MarkItemsInBloc( MODULE* module, EDA_Rect& Rect ) { case TYPE_EDGE_MODULE: pos = ( (EDGE_MODULE*) item )->m_Start; - if( Rect.Inside( pos ) ) + if( Rect.Contains( pos ) ) { item->m_Selected = IS_SELECTED; ItemsCount++; } pos = ( (EDGE_MODULE*) item )->m_End; - if( Rect.Inside( pos ) ) + if( Rect.Contains( pos ) ) { item->m_Selected = IS_SELECTED; ItemsCount++; @@ -688,7 +688,7 @@ int MarkItemsInBloc( MODULE* module, EDA_Rect& Rect ) case TYPE_TEXTE_MODULE: pos = ( (TEXTE_MODULE*) item )->GetPosition(); - if( Rect.Inside( pos ) ) + if( Rect.Contains( pos ) ) { item->m_Selected = IS_SELECTED; ItemsCount++; diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index a8c02939ac..30ca836d95 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -512,8 +512,16 @@ public: */ void DisplayInfo( WinEDA_DrawFrame* frame ); - void Draw( WinEDA_DrawPanel* panel, wxDC* DC, - int aDrawMode, const wxPoint& offset = ZeroOffset ); + /** + * Function Draw. + * Redraw the BOARD items but not cursors, axis or grid. + * @param aPanel = the panel relative to the board + * @param aDC = the curent device context + * @param aDrawMode = GR_COPY, GR_OR ... (not always used) + * @param aOffset = an draw offset value (default = 0,0) + */ + void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, + int aDrawMode, const wxPoint& aOffset = ZeroOffset ); /** * Function DrawHighLight diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index 86acad8551..733f5b8622 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -738,7 +738,7 @@ bool DIMENSION::HitTest( const wxPoint& ref_pos ) */ bool DIMENSION::HitTest( EDA_Rect& refArea ) { - if( refArea.Inside( m_Pos ) ) + if( refArea.Contains( m_Pos ) ) return true; return false; } diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index 5b23015de6..d5cc9ff4ac 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -487,9 +487,9 @@ bool DRAWSEGMENT::HitTest( const wxPoint& ref_pos ) */ bool DRAWSEGMENT::HitTest( EDA_Rect& refArea ) { - if( refArea.Inside( m_Start ) ) + if( refArea.Contains( m_Start ) ) return true; - if( refArea.Inside( m_End ) ) + if( refArea.Contains( m_End ) ) return true; return false; } diff --git a/pcbnew/class_mire.cpp b/pcbnew/class_mire.cpp index 1578cb4e8f..7f094f1498 100644 --- a/pcbnew/class_mire.cpp +++ b/pcbnew/class_mire.cpp @@ -200,7 +200,7 @@ bool MIREPCB::HitTest( const wxPoint& refPos ) */ bool MIREPCB::HitTest( EDA_Rect& refArea ) { - if( refArea.Inside( m_Pos ) ) + if( refArea.Contains( m_Pos ) ) return true; return false; } diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 85d7bbe2b6..7c7aabcc29 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -875,13 +875,12 @@ void MODULE::DisplayInfo( WinEDA_DrawFrame* frame ) bool MODULE::HitTest( const wxPoint& refPos ) { /* Calculation of the cursor coordinate relative to module */ - int spot_cX = refPos.x - m_Pos.x; - int spot_cY = refPos.y - m_Pos.y; + wxPoint pos = refPos - m_Pos; - RotatePoint( &spot_cX, &spot_cY, -m_Orient ); + RotatePoint( &pos, -m_Orient ); /* Check if cursor is in the rectangle. */ - if( m_BoundaryBox.Inside( spot_cX, spot_cY ) ) + if( m_BoundaryBox.Contains( pos ) ) return true; return false; diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index c6b54d74f9..1c6229281b 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -291,7 +291,7 @@ bool TEXTE_MODULE::HitTest( const wxPoint& refPos ) rel_pos = refPos; RotatePoint( &rel_pos, m_Pos, -GetDrawRotation() ); - if( area.Inside( rel_pos ) ) + if( area.Contains( rel_pos ) ) return true; return false; diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 8d909ba83c..b40525b3d8 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -1175,9 +1175,9 @@ bool TRACK::HitTest( const wxPoint& ref_pos ) */ bool TRACK::HitTest( EDA_Rect& refArea ) { - if( refArea.Inside( m_Start ) ) + if( refArea.Contains( m_Start ) ) return true; - if( refArea.Inside( m_End ) ) + if( refArea.Contains( m_End ) ) return true; return false; } diff --git a/pcbnew/dialogs/dialog_display_options.h b/pcbnew/dialogs/dialog_display_options.h index 8923cb2b55..71c075fddb 100644 --- a/pcbnew/dialogs/dialog_display_options.h +++ b/pcbnew/dialogs/dialog_display_options.h @@ -1,5 +1,5 @@ /** - * @file pcbnew/dialog_display_options.h + * @file pcbnew/dialogs/dialog_display_options.h */ #include "dialog_display_options_base.h" diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp index 7ee6185524..fa64804f5d 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp @@ -129,7 +129,7 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties() } -void DIALOG_MODULE_BOARD_EDITOR::OnCancelClick( wxCommandEvent& WXUNUSED( event ) ) +void DIALOG_MODULE_BOARD_EDITOR::OnCancelClick( wxCommandEvent& event ) { EndModal( -1 ); } diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp index 11e6af1550..b00516f18f 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp @@ -307,7 +307,7 @@ void DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DLib( wxCommandEvent& event ) /**********************************************************************/ -void DIALOG_MODULE_MODULE_EDITOR::OnCancelClick( wxCommandEvent& WXUNUSED (event) ) +void DIALOG_MODULE_MODULE_EDITOR::OnCancelClick( wxCommandEvent& event ) /**********************************************************************/ { EndModal( -1 ); diff --git a/pcbnew/dimension.cpp b/pcbnew/dimension.cpp index d65d81b70d..655a64ac0b 100644 --- a/pcbnew/dimension.cpp +++ b/pcbnew/dimension.cpp @@ -139,7 +139,7 @@ DIMENSION_EDITOR_DIALOG::DIMENSION_EDITOR_DIALOG( WinEDA_PcbFrame* parent, /**********************************************************************/ -void DIMENSION_EDITOR_DIALOG::OnCancelClick( wxCommandEvent& WXUNUSED (event) ) +void DIMENSION_EDITOR_DIALOG::OnCancelClick( wxCommandEvent& event ) /**********************************************************************/ { EndModal( -1 ); diff --git a/pcbnew/mirepcb.cpp b/pcbnew/mirepcb.cpp index 23a3aa5733..288df1e72e 100644 --- a/pcbnew/mirepcb.cpp +++ b/pcbnew/mirepcb.cpp @@ -124,7 +124,7 @@ TARGET_PROPERTIES_DIALOG_EDITOR::TARGET_PROPERTIES_DIALOG_EDITOR( } -void TARGET_PROPERTIES_DIALOG_EDITOR::OnCancelClick( wxCommandEvent& WXUNUSED( event ) ) +void TARGET_PROPERTIES_DIALOG_EDITOR::OnCancelClick( wxCommandEvent& event ) { EndModal( -1 ); } diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index e8300c35c9..1512d3495e 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -797,7 +797,7 @@ WinEDA_SetParamShapeFrame::WinEDA_SetParamShapeFrame( WinEDA_PcbFrame* parent, } -void WinEDA_SetParamShapeFrame::OnCancelClick( wxCommandEvent& WXUNUSED(event) ) +void WinEDA_SetParamShapeFrame::OnCancelClick( wxCommandEvent& event ) { if( PolyEdges ) free( PolyEdges ); diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index c57c852b2d..83ea203fd6 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -414,7 +414,7 @@ void WinEDA_PcbFrame::ReFillLayerWidget() } -void WinEDA_PcbFrame::OnQuit( wxCommandEvent & WXUNUSED(event) ) +void WinEDA_PcbFrame::OnQuit( wxCommandEvent& event ) { Close( true ); } diff --git a/pcbnew/pcbplot.cpp b/pcbnew/pcbplot.cpp index 3944c7b0fc..49c2193303 100644 --- a/pcbnew/pcbplot.cpp +++ b/pcbnew/pcbplot.cpp @@ -303,7 +303,7 @@ void DIALOG_PLOT::Init_Dialog() } -void DIALOG_PLOT::OnQuit( wxCommandEvent& WXUNUSED( event ) ) +void DIALOG_PLOT::OnQuit( wxCommandEvent& event ) { Close( true ); // true is to force the frame to close } diff --git a/pcbnew/xchgmod.cpp b/pcbnew/xchgmod.cpp index 01f5a44241..2bc9a77eb2 100644 --- a/pcbnew/xchgmod.cpp +++ b/pcbnew/xchgmod.cpp @@ -66,7 +66,7 @@ void WinEDA_PcbFrame::InstallExchangeModuleFrame( MODULE* Module ) } -void DIALOG_EXCHANGE_MODULE::OnQuit( wxCommandEvent& WXUNUSED( event ) ) +void DIALOG_EXCHANGE_MODULE::OnQuit( wxCommandEvent& event ) { s_SelectionMode = m_Selection->GetSelection(); Close( true ); // true is to force the frame to close diff --git a/pcbnew/zones_polygons_insulated_copper_islands.cpp b/pcbnew/zones_polygons_insulated_copper_islands.cpp index 9adb215fda..c6cf341fb2 100644 --- a/pcbnew/zones_polygons_insulated_copper_islands.cpp +++ b/pcbnew/zones_polygons_insulated_copper_islands.cpp @@ -90,7 +90,7 @@ void ZONE_CONTAINER::Test_For_Copper_Island_And_Remove_Insulated_Islands( BOARD ic++ ) { // test if this area is connected to a board item: wxPoint pos = ListPointsCandidates[ic]; - if( !bbox.Inside( pos ) ) + if( !bbox.Contains( pos ) ) continue; if( TestPointInsidePolygon( m_FilledPolysList, indexstart, diff --git a/pcbnew/zones_polygons_test_connections.cpp b/pcbnew/zones_polygons_test_connections.cpp index 0c6263ba34..b42ac20e1a 100644 --- a/pcbnew/zones_polygons_test_connections.cpp +++ b/pcbnew/zones_polygons_test_connections.cpp @@ -130,7 +130,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode ) else continue; bool connected = false; - if( bbox.Inside( pos1 ) ) + if( bbox.Contains( pos1 ) ) { if( TestPointInsidePolygon( curr_zone->m_FilledPolysList, indexstart, indexend, pos1.x, pos1.y ) ) @@ -138,7 +138,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode ) } if( !connected && (pos1 != pos2 ) ) { - if( bbox.Inside( pos2 ) ) + if( bbox.Contains( pos2 ) ) if( TestPointInsidePolygon( curr_zone->m_FilledPolysList, indexstart, indexend, pos2.x, pos2.y ) ) connected = true; diff --git a/version.txt b/version.txt index 6e0380fb82..794ef44203 100644 --- a/version.txt +++ b/version.txt @@ -1,4 +1,4 @@ release version: -2010 dec 18 (BZR testing 26xx) +2010 dec 22 (BZR testing 2676) files (.zip,.tgz): -kicad-2010-12-18-testing +kicad-2010-12-22-testing