diff --git a/eeschema/autoplace_fields.cpp b/eeschema/autoplace_fields.cpp index c7d15dc154..8cf15530d9 100644 --- a/eeschema/autoplace_fields.cpp +++ b/eeschema/autoplace_fields.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Chris Pavlina - * Copyright (C) 2015 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2015, 2019 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -66,14 +66,13 @@ #include #include -#define FIELD_PADDING 10 // arbitrarily chosen for aesthetics -#define FIELD_PADDING_ALIGNED 18 // aligns 50 mil text to a 100 mil grid -#define WIRE_V_SPACING 100 -#define HPADDING 25 -#define VPADDING 25 +#define FIELD_PADDING Mils2iu( 10 ) // arbitrarily chosen for aesthetics +#define FIELD_PADDING_ALIGNED Mils2iu( 18 ) // aligns 50 mil text to a 100 mil grid +#define WIRE_V_SPACING Mils2iu( 100 ) +#define HPADDING Mils2iu( 25 ) +#define VPADDING Mils2iu( 25 ) /** - * Function round_n * Round up/down to the nearest multiple of n */ template T round_n( const T& value, const T& n, bool aRoundUp ) @@ -86,8 +85,7 @@ template T round_n( const T& value, const T& n, bool aRoundUp ) /** - * Function TO_HJUSTIFY - * Converts an integer to a horizontal justification; neg=L zero=C pos=R + * Convert an integer to a horizontal justification; neg=L zero=C pos=R */ EDA_TEXT_HJUSTIFY_T TO_HJUSTIFY( int x ) { @@ -171,8 +169,8 @@ public: if( m_align_to_grid ) { - pos.x = round_n( pos.x, 50, field_side.x >= 0 ); - pos.y = round_n( pos.y, 50, field_side.y == 1 ); + pos.x = round_n( pos.x, Mils2iu( 50 ), field_side.x >= 0 ); + pos.y = round_n( pos.y, Mils2iu( 50 ), field_side.y == 1 ); } field->SetPosition( pos ); @@ -221,7 +219,6 @@ protected: /** - * Function get_pin_side * Return the side that a pin is on. */ SIDE get_pin_side( LIB_PIN* aPin ) @@ -241,7 +238,6 @@ protected: /** - * Function pins_on_side * Count the number of pins on a side of the component. */ unsigned pins_on_side( SIDE aSide ) @@ -264,7 +260,6 @@ protected: /** - * Function get_possible_colliders * Populate a list of all drawing items that *may* collide with the fields. That is, * all drawing items, including other fields, that are not the current component or * its own fields. @@ -289,7 +284,6 @@ protected: /** - * Function filtered_colliders * Filter a list of possible colliders to include only those that actually collide * with a given rectangle. Returns the new vector. */ @@ -312,7 +306,6 @@ protected: /** - * Function get_preferred_sides * Return a list with the preferred field sides for the component, in * decreasing order of preference. */ @@ -382,7 +375,6 @@ protected: /** - * Function get_colliding_sides * Return a list of the sides where a field set would collide with another item. */ std::vector get_colliding_sides() @@ -421,7 +413,6 @@ protected: /** - * Function choose_side_filtered * Choose a side for the fields, filtered on only one side collision type. * Removes the sides matching the filter from the list. */ @@ -457,7 +448,6 @@ protected: /** - * Function choose_side_for_fields * Look where a component's pins are to pick a side to put the fields on * @param aAvoidCollisions - if true, pick last the sides where the label will collide * with other items. @@ -495,7 +485,6 @@ protected: /** - * Function justify_field * Set the justification of a field based on the side it's supposed to be on, taking * into account whether the field will be displayed with flipped justification due to * mirroring. @@ -511,8 +500,7 @@ protected: /** - * Function field_box_placement - * Returns the position of the field bounding box. + * Return the position of the field bounding box. */ wxPoint field_box_placement( SIDE aFieldSide ) { @@ -532,7 +520,6 @@ protected: /** - * Function fit_fields_between_wires * Shift a field box up or down a bit to make the fields fit between some wires. * Returns true if a shift was made. */ @@ -588,9 +575,7 @@ protected: /** - * Function field_horiz_placement - * Place a field horizontally, taking into account the field width and - * justification. + * Place a field horizontally, taking into account the field width and justification. * * @param aField - the field to place. * @param aFieldBox - box in which fields will be placed @@ -627,7 +612,6 @@ protected: } /** - * Function field_vert_placement * Place a field vertically. Because field vertical placements accumulate, * this takes a pointer to a vertical position accumulator. * @@ -664,7 +648,6 @@ protected: } /** - * Function get_field_padding * Return the desired padding between fields. */ int get_field_padding() diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 863ac31533..f8568dd936 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -63,7 +63,7 @@ int GetDefaultBusThickness() } -void SetDefaultBusThickness( int aThickness) +void SetDefaultBusThickness( int aThickness ) { s_defaultBusThickness = std::max( 1, aThickness ); } @@ -252,6 +252,9 @@ bool SCH_EDIT_FRAME::LoadProjectFile() // Read schematic editor setup ret &= Prj().ConfigLoad( Kiface().KifaceSearch(), GROUP_SCH_EDIT, GetProjectFileParameters() ); + // Convert default text size to internal units. + SetDefaultTextSize( Mils2iu( GetDefaultTextSize() ) ); + // Verify some values, because the config file can be edited by hand, // and have bad values: LIB_PART::SetSubpartIdNotation( LIB_PART::GetSubpartIdSeparator(), @@ -293,7 +296,12 @@ void SCH_EDIT_FRAME::SaveProjectSettings( bool aAskForSave ) wxString path = fn.GetFullPath(); + // Convert default text size from internal units temporarily. + SetDefaultTextSize( Iu2Mils( GetDefaultTextSize() ) ); + prj.ConfigSave( Kiface().KifaceSearch(), GROUP_SCH_EDIT, GetProjectFileParameters(), path ); + + SetDefaultTextSize( Mils2iu( GetDefaultTextSize() ) ); } ///@{ @@ -357,12 +365,6 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetConfigurationSettings() m_configSettings.push_back( new PARAM_CFG_BOOL( true, PrintSheetRefEntry, &m_printSheetReference, true ) ); - m_configSettings.push_back( new PARAM_CFG_INT( true, RepeatStepXEntry, - &m_repeatStep.x, DEFAULT_REPEAT_OFFSET_X, - -REPEAT_OFFSET_MAX, REPEAT_OFFSET_MAX ) ); - m_configSettings.push_back( new PARAM_CFG_INT( true, RepeatStepYEntry, - &m_repeatStep.y, DEFAULT_REPEAT_OFFSET_Y, - -REPEAT_OFFSET_MAX, REPEAT_OFFSET_MAX ) ); m_configSettings.push_back( new PARAM_CFG_INT( true, RepeatLabelIncrementEntry, &m_repeatDeltaLabel, DEFAULT_REPEAT_LABEL_INC, -10, +10 ) ); @@ -383,20 +385,26 @@ void SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg ) wxConfigLoadSetups( aCfg, GetConfigurationSettings() ); + aCfg->Read( RepeatStepXEntry, &tmp, DEFAULT_REPEAT_OFFSET_X ); + m_repeatStep.x = Mils2iu( static_cast< int >( tmp ) ); + aCfg->Read( RepeatStepYEntry, &tmp, DEFAULT_REPEAT_OFFSET_Y ); + m_repeatStep.y = Mils2iu( static_cast< int >( tmp ) ); + // LibEdit owns this one, but we must read it in if LibEdit hasn't set it yet if( GetDefaultLineThickness() < 0 ) { - SetDefaultLineThickness( (int) aCfg->Read( DefaultDrawLineWidthEntry, - DEFAULTDRAWLINETHICKNESS ) ); + SetDefaultLineThickness( Mils2iu( (int) aCfg->Read( DefaultDrawLineWidthEntry, + DEFAULTDRAWLINETHICKNESS ) ) ); } - SetDefaultBusThickness( (int) aCfg->Read( DefaultBusWidthEntry, DEFAULTBUSTHICKNESS ) ); + SetDefaultBusThickness( Mils2iu( (int) aCfg->Read( DefaultBusWidthEntry, + DEFAULTBUSTHICKNESS ) ) ); // Property introduced in 6.0; use DefaultLineWidth for earlier projects if( !aCfg->Read( DefaultWireWidthEntry, &tmp ) ) aCfg->Read( DefaultDrawLineWidthEntry, &tmp, DEFAULTDRAWLINETHICKNESS ); - SetDefaultWireThickness( (int) tmp ); + SetDefaultWireThickness( Mils2iu( (int) tmp ) ); SetSelectionTextAsBox( aCfg->ReadBool( boxedSelectedText, false ) ); SetSelectionDrawChildItems( aCfg->ReadBool( drawSelectedChildren, true ) ); @@ -407,7 +415,7 @@ void SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg ) SetTextMarkupFlags( (int) aCfg->Read( TextMarkupFlagsEntry, 0L ) ); if( aCfg->Read( DefaultJctSizeEntry, &tmp ) ) - SCH_JUNCTION::SetSymbolSize( (int) tmp ); + SCH_JUNCTION::SetSymbolSize( Mils2iu( (int) tmp ) ); aCfg->Read( DragActionIsMoveEntry, &m_dragActionIsMove, true ); aCfg->Read( ShowHiddenPinsEntry, &m_showAllPins, false ); @@ -450,10 +458,12 @@ void SCH_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg ) wxConfigSaveSetups( aCfg, GetConfigurationSettings() ); + aCfg->Write( RepeatStepXEntry, static_cast< long >( Iu2Mils( m_repeatStep.x ) ) ); + aCfg->Write( RepeatStepYEntry, static_cast< long >( Iu2Mils( m_repeatStep.y ) ) ); aCfg->Write( DragActionIsMoveEntry, m_dragActionIsMove ); - aCfg->Write( DefaultBusWidthEntry, (long) GetDefaultBusThickness() ); - aCfg->Write( DefaultWireWidthEntry, (long) GetDefaultWireThickness() ); - aCfg->Write( DefaultJctSizeEntry, (long) SCH_JUNCTION::GetSymbolSize() ); + aCfg->Write( DefaultBusWidthEntry, (long) Iu2Mils( GetDefaultBusThickness() ) ); + aCfg->Write( DefaultWireWidthEntry, (long) Iu2Mils( GetDefaultWireThickness() ) ); + aCfg->Write( DefaultJctSizeEntry, (long) Iu2Mils( SCH_JUNCTION::GetSymbolSize() ) ); aCfg->Write( ShowHiddenPinsEntry, m_showAllPins ); aCfg->Write( SelectPinSelectSymbolEntry, GetSelectPinSelectSymbol() ); aCfg->Write( HorzVertLinesOnlyEntry, GetForceHVLines() ); @@ -485,17 +495,23 @@ void LIB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg ) { EDA_DRAW_FRAME::LoadSettings( aCfg ); - SetDefaultLineThickness( (int) aCfg->Read( DefaultDrawLineWidthEntry, - DEFAULTDRAWLINETHICKNESS ) ); - SetDefaultPinLength( (int) aCfg->Read( DefaultPinLengthEntry, DEFAULTPINLENGTH ) ); - m_textPinNumDefaultSize = (int) aCfg->Read( defaultPinNumSizeEntry, DEFAULTPINNUMSIZE ); - m_textPinNameDefaultSize = (int) aCfg->Read( defaultPinNameSizeEntry, DEFAULTPINNAMESIZE ); + SetDefaultLineThickness( Mils2iu( (int) aCfg->Read( DefaultDrawLineWidthEntry, + DEFAULTDRAWLINETHICKNESS ) ) ); + SetDefaultPinLength( Mils2iu( (int) aCfg->Read( DefaultPinLengthEntry, DEFAULTPINLENGTH ) ) ); + m_textPinNumDefaultSize = Mils2iu( (int) aCfg->Read( defaultPinNumSizeEntry, + DEFAULTPINNUMSIZE ) ); + m_textPinNameDefaultSize = Mils2iu( (int) aCfg->Read( defaultPinNameSizeEntry, + DEFAULTPINNAMESIZE ) ); SetRepeatDeltaLabel( (int) aCfg->Read( repeatLibLabelIncEntry, DEFAULT_REPEAT_LABEL_INC ) ); - SetRepeatPinStep( (int) aCfg->Read( pinRepeatStepEntry, DEFAULT_REPEAT_OFFSET_PIN ) ); + SetRepeatPinStep( Mils2iu( (int) aCfg->Read( pinRepeatStepEntry, + DEFAULT_REPEAT_OFFSET_PIN ) ) ); wxPoint step; - aCfg->Read( repeatLibStepXEntry, &step.x, DEFAULT_REPEAT_OFFSET_X ); - aCfg->Read( repeatLibStepYEntry, &step.y, DEFAULT_REPEAT_OFFSET_Y ); + step.x = Mils2iu( static_cast< int >( aCfg->Read( repeatLibStepXEntry, + static_cast< long >( DEFAULT_REPEAT_OFFSET_X ) ) ) ); + step.y = Mils2iu( static_cast< int >( aCfg->Read( repeatLibStepYEntry, + static_cast< long >( DEFAULT_REPEAT_OFFSET_Y ) ) ) ); + SetRepeatStep( step ); m_showPinElectricalTypeName = aCfg->ReadBool( showPinElectricalType, true ); aCfg->Read( defaultLibWidthEntry, &m_defaultLibWidth, DEFAULTLIBWIDTH ); @@ -532,14 +548,14 @@ void LIB_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg ) { EDA_DRAW_FRAME::SaveSettings( aCfg ); - aCfg->Write( DefaultDrawLineWidthEntry, GetDefaultLineThickness() ); - aCfg->Write( DefaultPinLengthEntry, GetDefaultPinLength() ); - aCfg->Write( defaultPinNumSizeEntry, GetPinNumDefaultSize() ); - aCfg->Write( defaultPinNameSizeEntry, GetPinNameDefaultSize() ); + aCfg->Write( DefaultDrawLineWidthEntry, Iu2Mils( GetDefaultLineThickness() ) ); + aCfg->Write( DefaultPinLengthEntry, Iu2Mils( GetDefaultPinLength() ) ); + aCfg->Write( defaultPinNumSizeEntry, Iu2Mils( GetPinNumDefaultSize() ) ); + aCfg->Write( defaultPinNameSizeEntry, Iu2Mils( GetPinNameDefaultSize() ) ); aCfg->Write( repeatLibLabelIncEntry, GetRepeatDeltaLabel() ); - aCfg->Write( pinRepeatStepEntry, GetRepeatPinStep() ); - aCfg->Write( repeatLibStepXEntry, GetRepeatStep().x ); - aCfg->Write( repeatLibStepYEntry, GetRepeatStep().y ); + aCfg->Write( pinRepeatStepEntry, Iu2Mils( GetRepeatPinStep() ) ); + aCfg->Write( repeatLibStepXEntry, Iu2Mils( GetRepeatStep().x ) ); + aCfg->Write( repeatLibStepYEntry, Iu2Mils( GetRepeatStep().y ) ); aCfg->Write( showPinElectricalType, GetShowElectricalType() ); aCfg->Write( defaultLibWidthEntry, m_treePane->GetSize().x ); } diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index 2dfc9cd932..12dae366ee 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -59,7 +59,8 @@ LIB_ARC::LIB_ARC( LIB_PART* aParent ) : LIB_ITEM( LIB_ARC_T, aParent ) bool LIB_ARC::HitTest( const wxPoint& aRefPoint, int aAccuracy ) const { - int mindist = std::max( aAccuracy + GetPenSize() / 2, MINIMUM_SELECTION_DISTANCE ); + int mindist = std::max( aAccuracy + GetPenSize() / 2, + Mils2iu( MINIMUM_SELECTION_DISTANCE ) ); wxPoint relativePosition = aRefPoint; relativePosition.y = -relativePosition.y; // reverse Y axis diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp index 01424c0374..0c2ee97946 100644 --- a/eeschema/lib_bezier.cpp +++ b/eeschema/lib_bezier.cpp @@ -248,7 +248,8 @@ void LIB_BEZIER::print( wxDC* aDC, const wxPoint& aOffset, void* aData, bool LIB_BEZIER::HitTest( const wxPoint& aRefPos, int aAccuracy ) const { - int mindist = std::max( aAccuracy + GetPenSize() / 2, MINIMUM_SELECTION_DISTANCE ); + int mindist = std::max( aAccuracy + GetPenSize() / 2, + Mils2iu( MINIMUM_SELECTION_DISTANCE ) ); wxPoint start, end; for( unsigned ii = 1; ii < GetCornerCount(); ii++ ) diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index c84ada5460..e686881c8c 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -48,7 +48,8 @@ LIB_CIRCLE::LIB_CIRCLE( LIB_PART* aParent ) : bool LIB_CIRCLE::HitTest( const wxPoint& aPosRef, int aAccuracy ) const { - int mindist = std::max( aAccuracy + GetPenSize() / 2, MINIMUM_SELECTION_DISTANCE ); + int mindist = std::max( aAccuracy + GetPenSize() / 2, + Mils2iu( MINIMUM_SELECTION_DISTANCE ) ); int dist = KiROUND( GetLineLength( aPosRef, DefaultTransform.TransformCoordinate( m_Pos ) ) ); if( abs( dist - GetRadius() ) <= mindist ) diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 9c0769be4c..40bf268e67 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -699,8 +699,10 @@ void LIB_PIN::PrintPinTexts( wxDC* DC, wxPoint& pin_pos, int orient, int TextIns wxSize PinNumSize( m_numTextSize, m_numTextSize ); int nameLineWidth = Clamp_Text_PenSize( GetPenSize(), m_nameTextSize, false ); int numLineWidth = Clamp_Text_PenSize( GetPenSize(), m_numTextSize, false ); - int name_offset = PIN_TEXT_MARGIN + ( nameLineWidth + GetDefaultLineThickness() ) / 2; - int num_offset = PIN_TEXT_MARGIN + ( numLineWidth + GetDefaultLineThickness() ) / 2; + int name_offset = Mils2iu( PIN_TEXT_MARGIN ) + + ( nameLineWidth + GetDefaultLineThickness() ) / 2; + int num_offset = Mils2iu( PIN_TEXT_MARGIN ) + + ( numLineWidth + GetDefaultLineThickness() ) / 2; /* Get the num and name colors */ COLOR4D NameColor = IsVisible() ? GetLayerColor( LAYER_PINNAM ) : GetInvisibleItemColor(); @@ -1023,9 +1025,9 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient, int numLineWidth = GetPenSize(); numLineWidth = Clamp_Text_PenSize( numLineWidth, m_numTextSize, false ); - int name_offset = PIN_TEXT_MARGIN + + int name_offset = Mils2iu( PIN_TEXT_MARGIN ) + ( nameLineWidth + GetDefaultLineThickness() ) / 2; - int num_offset = PIN_TEXT_MARGIN + + int num_offset = Mils2iu( PIN_TEXT_MARGIN ) + ( numLineWidth + GetDefaultLineThickness() ) / 2; /* Get the num and name colors */ @@ -1479,7 +1481,7 @@ const EDA_RECT LIB_PIN::GetBoundingBox( bool aIncludeInvisibles ) const // calculate top left corner position // for the default pin orientation (PIN_RIGHT) - begin.y = std::max( minsizeV, numberTextHeight + PIN_TEXT_MARGIN ); + begin.y = std::max( minsizeV, numberTextHeight + Mils2iu( PIN_TEXT_MARGIN ) ); begin.x = std::min( -TARGET_PIN_RADIUS, m_length - (numberTextLength / 2) ); // calculate bottom right corner position and adjust top left corner position @@ -1497,7 +1499,7 @@ const EDA_RECT LIB_PIN::GetBoundingBox( bool aIncludeInvisibles ) const nameTextLength = ( m_nameTextSize * length ) + nameTextOffset; // Actual text height are bigger than text size - nameTextHeight = KiROUND( m_nameTextSize * 1.1 ) + PIN_TEXT_MARGIN; + nameTextHeight = KiROUND( m_nameTextSize * 1.1 ) + Mils2iu( PIN_TEXT_MARGIN ); } if( nameTextOffset ) // for values > 0, pin name is inside the body diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index 6adc3fdb71..200d036d27 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -3,7 +3,7 @@ * * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr * Copyright (C) 2015 Wayne Stambaugh - * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2019 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -40,7 +40,7 @@ class SCH_COMPONENT; #include "class_libentry.h" // Circle diameter drawn at the active end of pins: -#define TARGET_PIN_RADIUS 15 +#define TARGET_PIN_RADIUS Mils2iu( 15 ) // Pin visibility flag bit: #define PIN_INVISIBLE 1 // Set makes pin invisible diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp index 4daac8489e..6bc089b01e 100644 --- a/eeschema/lib_polyline.cpp +++ b/eeschema/lib_polyline.cpp @@ -228,7 +228,8 @@ void LIB_POLYLINE::print( wxDC* aDC, const wxPoint& aOffset, void* aData, bool LIB_POLYLINE::HitTest( const wxPoint& aPosition, int aAccuracy ) const { - int delta = std::max( aAccuracy + GetPenSize() / 2, MINIMUM_SELECTION_DISTANCE ); + int delta = std::max( aAccuracy + GetPenSize() / 2, + Mils2iu( MINIMUM_SELECTION_DISTANCE ) ); SHAPE_LINE_CHAIN shape; for( wxPoint pt : m_PolyPoints ) diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp index 4bf6a1af2c..15c30e7ad4 100644 --- a/eeschema/lib_rectangle.cpp +++ b/eeschema/lib_rectangle.cpp @@ -208,7 +208,8 @@ const EDA_RECT LIB_RECTANGLE::GetBoundingBox() const bool LIB_RECTANGLE::HitTest( const wxPoint& aPosition, int aAccuracy ) const { - int mindist = std::max( aAccuracy + GetPenSize() / 2, MINIMUM_SELECTION_DISTANCE ); + int mindist = std::max( aAccuracy + GetPenSize() / 2, + Mils2iu( MINIMUM_SELECTION_DISTANCE ) ); wxPoint actualStart = DefaultTransform.TransformCoordinate( m_Pos ); wxPoint actualEnd = DefaultTransform.TransformCoordinate( m_End ); diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 5dc3183b76..7f0244f4c7 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -46,7 +46,7 @@ LIB_TEXT::LIB_TEXT( LIB_PART * aParent ) : LIB_ITEM( LIB_TEXT_T, aParent ), EDA_TEXT() { - SetTextSize( wxSize( 50, 50 ) ); + SetTextSize( wxSize( Mils2iu( 50 ), Mils2iu( 50 ) ) ); } diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index c2dcdd2ef8..8db9a07ddf 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -82,12 +82,13 @@ SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aWindo { createCanvas(); - m_zoomLevelCoeff = 11.0; // Adjusted to roughly displays zoom level = 1 - // when the screen shows a 1:1 image - // obviously depends on the monitor, - // but this is an acceptable value - m_repeatStep = wxPoint( DEFAULT_REPEAT_OFFSET_X, DEFAULT_REPEAT_OFFSET_Y ); - m_repeatDeltaLabel = DEFAULT_REPEAT_LABEL_INC; + m_zoomLevelCoeff = 11.0 * IU_PER_MILS; // Adjusted to roughly displays zoom level = 1 + // when the screen shows a 1:1 image + // obviously depends on the monitor, + // but this is an acceptable value + m_repeatStep = wxPoint( Mils2iu( DEFAULT_REPEAT_OFFSET_X ), + Mils2iu( DEFAULT_REPEAT_OFFSET_Y ) ); + m_repeatDeltaLabel = Mils2iu( DEFAULT_REPEAT_LABEL_INC ); m_showPinElectricalTypeName = false; m_repeatComponent = false; m_useAllUnits = false; diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h index 6de4d29c55..cf726941b3 100644 --- a/eeschema/sch_bus_entry.h +++ b/eeschema/sch_bus_entry.h @@ -32,7 +32,7 @@ #include -#define TARGET_BUSENTRY_RADIUS 12 // Circle diameter drawn at the ends +#define TARGET_BUSENTRY_RADIUS Mils2iu( 12 ) // Circle diameter drawn at the ends /** @@ -56,7 +56,6 @@ public: ~SCH_BUS_ENTRY_BASE() { } /** - * Virtual function IsMovableFromAnchorPoint * Return true for items which are moved with the anchor point at mouse cursor * and false for items moved with no reference to anchor * @return false for a bus entry @@ -66,13 +65,11 @@ public: wxPoint m_End() const; /** - * function GetBusEntryShape * @return the shape of the bus entry, as an ascii code '/' or '\' */ char GetBusEntryShape() const; /** - * function SetBusEntryShape * @param aShape = the shape of the bus entry, as an ascii code '/' or '\' */ void SetBusEntryShape( char aShape ); diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 07b164dedd..ae86a337c9 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -97,12 +97,12 @@ static LIB_PART* dummy() LIB_RECTANGLE* square = new LIB_RECTANGLE( part ); - square->MoveTo( wxPoint( -200, 200 )); - square->SetEndPosition( wxPoint( 200, -200 ) ); + square->MoveTo( wxPoint( Mils2iu( -200 ), Mils2iu( 200 ) ) ); + square->SetEndPosition( wxPoint( Mils2iu( 200 ), Mils2iu( -200 ) ) ); LIB_TEXT* text = new LIB_TEXT( part ); - text->SetTextSize( wxSize( 150, 150 ) ); + text->SetTextSize( wxSize( Mils2iu( 150 ), Mils2iu( 150 ) ) ); text->SetText( wxString( wxT( "??" ) ) ); part->AddDrawItem( square ); @@ -563,7 +563,7 @@ void SCH_COMPONENT::Print( wxDC* aDC, const wxPoint& aOffset ) SCH_FIELD* field = GetField( REFERENCE ); if( field->IsVisible() ) - field->Print(aDC, aOffset ); + field->Print( aDC, aOffset ); for( int ii = VALUE; ii < GetFieldCount(); ii++ ) { @@ -692,11 +692,13 @@ void SCH_COMPONENT::SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref ) SCH_FIELD* rf = GetField( REFERENCE ); + // @todo Should we really be checking for what is a "reasonable" position? if( rf->GetText().IsEmpty() - || ( abs( rf->GetTextPos().x - m_Pos.x ) + abs( rf->GetTextPos().y - m_Pos.y ) > 10000 ) ) + || ( abs( rf->GetTextPos().x - m_Pos.x ) + + abs( rf->GetTextPos().y - m_Pos.y ) > Mils2iu( 10000 ) ) ) { // move it to a reasonable position - rf->SetTextPos( m_Pos + wxPoint( 50, 50 ) ); + rf->SetTextPos( m_Pos + wxPoint( Mils2iu( 50 ), Mils2iu( 50 ) ) ); } rf->SetText( ref ); // for drawing. diff --git a/eeschema/sch_draw_panel.cpp b/eeschema/sch_draw_panel.cpp index ce987d6aa4..5995dd2923 100644 --- a/eeschema/sch_draw_panel.cpp +++ b/eeschema/sch_draw_panel.cpp @@ -63,7 +63,7 @@ SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId, m_painter.reset( new KIGFX::SCH_PAINTER( m_gal ) ); m_view->SetPainter( m_painter.get() ); - m_view->SetScaleLimits( 50.0, 0.05 ); // This fixes the zoom in and zoom out limits + m_view->SetScaleLimits( 1000.0, 0.0001 ); // This fixes the zoom in and zoom out limits m_view->SetMirror( false, false ); // Early initialization of the canvas background color, diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp index fba4018e78..e9d6981c8c 100644 --- a/eeschema/sch_legacy_plugin.cpp +++ b/eeschema/sch_legacy_plugin.cpp @@ -67,6 +67,9 @@ #include +#define Mils2Iu( x ) Mils2iu( x ) + + // Must be the first line of part library document (.dcm) files. #define DOCFILE_IDENT "EESchema-DOCLIB Version 2.0" @@ -975,14 +978,14 @@ SCH_SHEET* SCH_LEGACY_PLUGIN::loadSheet( LINE_READER& aReader ) { wxPoint position; - position.x = parseInt( aReader, line, &line ); - position.y = parseInt( aReader, line, &line ); + position.x = Mils2Iu( parseInt( aReader, line, &line ) ); + position.y = Mils2Iu( parseInt( aReader, line, &line ) ); sheet->SetPosition( position ); wxSize size; - size.SetWidth( parseInt( aReader, line, &line ) ); - size.SetHeight( parseInt( aReader, line, &line ) ); + size.SetWidth( Mils2Iu( parseInt( aReader, line, &line ) ) ); + size.SetHeight( Mils2Iu( parseInt( aReader, line, &line ) ) ); sheet->SetSize( size ); } else if( strCompare( "U", line, &line ) ) // Sheet time stamp. @@ -1000,7 +1003,7 @@ SCH_SHEET* SCH_LEGACY_PLUGIN::loadSheet( LINE_READER& aReader ) if( fieldId == 0 || fieldId == 1 ) // Sheet name and file name. { parseQuotedString( text, aReader, line, &line ); - size = parseInt( aReader, line, &line ); + size = Mils2Iu( parseInt( aReader, line, &line ) ); if( fieldId == 0 ) { @@ -1064,11 +1067,11 @@ SCH_SHEET* SCH_LEGACY_PLUGIN::loadSheet( LINE_READER& aReader ) wxPoint position; - position.x = parseInt( aReader, line, &line ); - position.y = parseInt( aReader, line, &line ); + position.x = Mils2Iu( parseInt( aReader, line, &line ) ); + position.y = Mils2Iu( parseInt( aReader, line, &line ) ); sheetPin->SetPosition( position ); - size = parseInt( aReader, line, &line ); + size = Mils2Iu( parseInt( aReader, line, &line ) ); sheetPin->SetTextSize( wxSize( size, size ) ); @@ -1103,8 +1106,8 @@ SCH_BITMAP* SCH_LEGACY_PLUGIN::loadBitmap( LINE_READER& aReader ) { wxPoint position; - position.x = parseInt( aReader, line, &line ); - position.y = parseInt( aReader, line, &line ); + position.x = Mils2Iu( parseInt( aReader, line, &line ) ); + position.y = Mils2Iu( parseInt( aReader, line, &line ) ); bitmap->SetPosition( position ); } else if( strCompare( "Scale", line, &line ) ) @@ -1186,8 +1189,8 @@ SCH_JUNCTION* SCH_LEGACY_PLUGIN::loadJunction( LINE_READER& aReader ) wxPoint position; - position.x = parseInt( aReader, line, &line ); - position.y = parseInt( aReader, line, &line ); + position.x = Mils2Iu( parseInt( aReader, line, &line ) ); + position.y = Mils2Iu( parseInt( aReader, line, &line ) ); junction->SetPosition( position ); return junction.release(); @@ -1208,8 +1211,8 @@ SCH_NO_CONNECT* SCH_LEGACY_PLUGIN::loadNoConnect( LINE_READER& aReader ) wxPoint position; - position.x = parseInt( aReader, line, &line ); - position.y = parseInt( aReader, line, &line ); + position.x = Mils2Iu( parseInt( aReader, line, &line ) ); + position.y = Mils2Iu( parseInt( aReader, line, &line ) ); no_connect->SetPosition( position ); return no_connect.release(); @@ -1249,7 +1252,7 @@ SCH_LINE* SCH_LEGACY_PLUGIN::loadWire( LINE_READER& aReader ) else if( buf == T_WIDTH ) { - int size = parseInt( aReader, line, &line ); + int size = Mils2Iu( parseInt( aReader, line, &line ) ); wire->SetLineWidth( size ); } else if( buf == T_STYLE ) @@ -1302,10 +1305,10 @@ SCH_LINE* SCH_LEGACY_PLUGIN::loadWire( LINE_READER& aReader ) wxPoint begin, end; - begin.x = parseInt( aReader, line, &line ); - begin.y = parseInt( aReader, line, &line ); - end.x = parseInt( aReader, line, &line ); - end.y = parseInt( aReader, line, &line ); + begin.x = Mils2Iu( parseInt( aReader, line, &line ) ); + begin.y = Mils2Iu( parseInt( aReader, line, &line ) ); + end.x = Mils2Iu( parseInt( aReader, line, &line ) ); + end.y = Mils2Iu( parseInt( aReader, line, &line ) ); wire->SetStartPoint( begin ); wire->SetEndPoint( end ); @@ -1344,10 +1347,10 @@ SCH_BUS_ENTRY_BASE* SCH_LEGACY_PLUGIN::loadBusEntry( LINE_READER& aReader ) wxPoint pos; wxSize size; - pos.x = parseInt( aReader, line, &line ); - pos.y = parseInt( aReader, line, &line ); - size.x = parseInt( aReader, line, &line ); - size.y = parseInt( aReader, line, &line ); + pos.x = Mils2Iu( parseInt( aReader, line, &line ) ); + pos.y = Mils2Iu( parseInt( aReader, line, &line ) ); + size.x = Mils2Iu( parseInt( aReader, line, &line ) ); + size.y = Mils2Iu( parseInt( aReader, line, &line ) ); size.x -= pos.x; size.y -= pos.y; @@ -1387,12 +1390,12 @@ SCH_TEXT* SCH_LEGACY_PLUGIN::loadText( LINE_READER& aReader ) // Parse the parameters common to all text objects. wxPoint position; - position.x = parseInt( aReader, line, &line ); - position.y = parseInt( aReader, line, &line ); + position.x = Mils2Iu( parseInt( aReader, line, &line ) ); + position.y = Mils2Iu( parseInt( aReader, line, &line ) ); text->SetPosition( position ); text->SetLabelSpinStyle( parseInt( aReader, line, &line ) ); - int size = parseInt( aReader, line, &line ); + int size = Mils2Iu( parseInt( aReader, line, &line ) ); text->SetTextSize( wxSize( size, size ) ); @@ -1557,8 +1560,8 @@ SCH_COMPONENT* SCH_LEGACY_PLUGIN::loadComponent( LINE_READER& aReader ) { wxPoint pos; - pos.x = parseInt( aReader, line, &line ); - pos.y = parseInt( aReader, line, &line ); + pos.x = Mils2Iu( parseInt( aReader, line, &line ) ); + pos.y = Mils2Iu( parseInt( aReader, line, &line ) ); component->SetPosition( pos ); } else if( strCompare( "AR", line, &line ) ) @@ -1614,9 +1617,9 @@ SCH_COMPONENT* SCH_LEGACY_PLUGIN::loadComponent( LINE_READER& aReader ) char orientation = parseChar( aReader, line, &line ); wxPoint pos; - pos.x = parseInt( aReader, line, &line ); - pos.y = parseInt( aReader, line, &line ); - int size = parseInt( aReader, line, &line ); + pos.x = Mils2Iu( parseInt( aReader, line, &line ) ); + pos.y = Mils2Iu( parseInt( aReader, line, &line ) ); + int size = Mils2Iu( parseInt( aReader, line, &line ) ); int attributes = parseHex( aReader, line, &line ); if( index >= component->GetFieldCount() ) @@ -1979,7 +1982,9 @@ void SCH_LEGACY_PLUGIN::saveComponent( SCH_COMPONENT* aComponent ) aComponent->GetTimeStamp() ); // Save the position - m_out->Print( 0, "P %d %d\n", aComponent->GetPosition().x, aComponent->GetPosition().y ); + m_out->Print( 0, "P %d %d\n", + Iu2Mils( aComponent->GetPosition().x ), + Iu2Mils( aComponent->GetPosition().y ) ); /* If this is a complex hierarchy; save hierarchical references. * but for simple hierarchies it is not necessary. @@ -2027,8 +2032,9 @@ void SCH_LEGACY_PLUGIN::saveComponent( SCH_COMPONENT* aComponent ) saveField( aComponent->GetField( i ) ); // Unit number, position, box ( old standard ) - m_out->Print( 0, "\t%-4d %-4d %-4d\n", aComponent->GetUnit(), aComponent->GetPosition().x, - aComponent->GetPosition().y ); + m_out->Print( 0, "\t%-4d %-4d %-4d\n", aComponent->GetUnit(), + Iu2Mils( aComponent->GetPosition().x ), + Iu2Mils( aComponent->GetPosition().y ) ); TRANSFORM transform = aComponent->GetTransform(); @@ -2058,8 +2064,9 @@ void SCH_LEGACY_PLUGIN::saveField( SCH_FIELD* aField ) aField->GetId(), EscapedUTF8( aField->GetText() ).c_str(), // wraps in quotes too aField->GetTextAngle() == TEXT_ANGLE_HORIZ ? 'H' : 'V', - aField->GetLibPosition().x, aField->GetLibPosition().y, - aField->GetTextWidth(), + Iu2Mils( aField->GetLibPosition().x ), + Iu2Mils( aField->GetLibPosition().y ), + Iu2Mils( aField->GetTextWidth() ), !aField->IsVisible(), hjustify, vjustify, aField->IsItalic() ? 'I' : 'N', @@ -2084,7 +2091,9 @@ void SCH_LEGACY_PLUGIN::saveBitmap( SCH_BITMAP* aBitmap ) wxCHECK_RET( image != NULL, "wxImage* is NULL" ); m_out->Print( 0, "$Bitmap\n" ); - m_out->Print( 0, "Pos %-4d %-4d\n", aBitmap->GetPosition().x, aBitmap->GetPosition().y ); + m_out->Print( 0, "Pos %-4d %-4d\n", + Iu2Mils( aBitmap->GetPosition().x ), + Iu2Mils( aBitmap->GetPosition().y ) ); m_out->Print( 0, "Scale %f\n", aBitmap->GetImage()->GetScale() ); m_out->Print( 0, "Data\n" ); @@ -2119,18 +2128,18 @@ void SCH_LEGACY_PLUGIN::saveSheet( SCH_SHEET* aSheet ) m_out->Print( 0, "$Sheet\n" ); m_out->Print( 0, "S %-4d %-4d %-4d %-4d\n", - aSheet->GetPosition().x, aSheet->GetPosition().y, - aSheet->GetSize().x, aSheet->GetSize().y ); + Iu2Mils( aSheet->GetPosition().x ), Iu2Mils( aSheet->GetPosition().y ), + Iu2Mils( aSheet->GetSize().x ), Iu2Mils( aSheet->GetSize().y ) ); m_out->Print( 0, "U %8.8X\n", aSheet->GetTimeStamp() ); if( !aSheet->GetName().IsEmpty() ) m_out->Print( 0, "F0 %s %d\n", EscapedUTF8( aSheet->GetName() ).c_str(), - aSheet->GetSheetNameSize() ); + Iu2Mils( aSheet->GetSheetNameSize() ) ); if( !aSheet->GetFileName().IsEmpty() ) m_out->Print( 0, "F1 %s %d\n", EscapedUTF8( aSheet->GetFileName() ).c_str(), - aSheet->GetFileNameSize() ); + Iu2Mils( aSheet->GetFileNameSize() ) ); for( const SCH_SHEET_PIN& pin : aSheet->GetPins() ) { @@ -2160,8 +2169,9 @@ void SCH_LEGACY_PLUGIN::saveSheet( SCH_SHEET* aSheet ) m_out->Print( 0, "F%d %s %c %c %-3d %-3d %-3d\n", pin.GetNumber(), EscapedUTF8( pin.GetText() ).c_str(), // supplies wrapping quotes - type, side, pin.GetPosition().x, pin.GetPosition().y, - pin.GetTextWidth() ); + type, side, Iu2Mils( pin.GetPosition().x ), + Iu2Mils( pin.GetPosition().y ), + Iu2Mils( pin.GetTextWidth() ) ); } m_out->Print( 0, "$EndSheet\n" ); @@ -2173,7 +2183,7 @@ void SCH_LEGACY_PLUGIN::saveJunction( SCH_JUNCTION* aJunction ) wxCHECK_RET( aJunction != NULL, "SCH_JUNCTION* is NULL" ); m_out->Print( 0, "Connection ~ %-4d %-4d\n", - aJunction->GetPosition().x, aJunction->GetPosition().y ); + Iu2Mils( aJunction->GetPosition().x ), Iu2Mils( aJunction->GetPosition().y ) ); } @@ -2181,8 +2191,8 @@ void SCH_LEGACY_PLUGIN::saveNoConnect( SCH_NO_CONNECT* aNoConnect ) { wxCHECK_RET( aNoConnect != NULL, "SCH_NOCONNECT* is NULL" ); - m_out->Print( 0, "NoConn ~ %-4d %-4d\n", aNoConnect->GetPosition().x, - aNoConnect->GetPosition().y ); + m_out->Print( 0, "NoConn ~ %-4d %-4d\n", Iu2Mils( aNoConnect->GetPosition().x ), + Iu2Mils( aNoConnect->GetPosition().y ) ); } @@ -2192,12 +2202,14 @@ void SCH_LEGACY_PLUGIN::saveBusEntry( SCH_BUS_ENTRY_BASE* aBusEntry ) if( aBusEntry->GetLayer() == LAYER_WIRE ) m_out->Print( 0, "Entry Wire Line\n\t%-4d %-4d %-4d %-4d\n", - aBusEntry->GetPosition().x, aBusEntry->GetPosition().y, - aBusEntry->m_End().x, aBusEntry->m_End().y ); + Iu2Mils( aBusEntry->GetPosition().x ), + Iu2Mils( aBusEntry->GetPosition().y ), + Iu2Mils( aBusEntry->m_End().x ), Iu2Mils( aBusEntry->m_End().y ) ); else m_out->Print( 0, "Entry Bus Bus\n\t%-4d %-4d %-4d %-4d\n", - aBusEntry->GetPosition().x, aBusEntry->GetPosition().y, - aBusEntry->m_End().x, aBusEntry->m_End().y ); + Iu2Mils( aBusEntry->GetPosition().x ), + Iu2Mils( aBusEntry->GetPosition().y ), + Iu2Mils( aBusEntry->m_End().x ), Iu2Mils( aBusEntry->m_End().y ) ); } @@ -2219,10 +2231,11 @@ void SCH_LEGACY_PLUGIN::saveLine( SCH_LINE* aLine ) if( aLine->IsGraphicLine() ) { if( aLine->GetPenSize() != aLine->GetDefaultWidth() ) - m_out->Print( 0, " %s %d", T_WIDTH, aLine->GetLineSize() ); + m_out->Print( 0, " %s %d", T_WIDTH, Iu2Mils( aLine->GetLineSize() ) ); if( aLine->GetLineStyle() != aLine->GetDefaultStyle() ) - m_out->Print( 0, " %s %s", T_STYLE, SCH_LINE::GetLineStyleName( aLine->GetLineStyle() ) ); + m_out->Print( 0, " %s %s", T_STYLE, + SCH_LINE::GetLineStyleName( aLine->GetLineStyle() ) ); if( aLine->GetLineColor() != aLine->GetDefaultColor() ) m_out->Print( 0, " %s", @@ -2232,8 +2245,8 @@ void SCH_LEGACY_PLUGIN::saveLine( SCH_LINE* aLine ) m_out->Print( 0, "\n" ); m_out->Print( 0, "\t%-4d %-4d %-4d %-4d", - aLine->GetStartPoint().x, aLine->GetStartPoint().y, - aLine->GetEndPoint().x, aLine->GetEndPoint().y ); + Iu2Mils( aLine->GetStartPoint().x ), Iu2Mils( aLine->GetStartPoint().y ), + Iu2Mils( aLine->GetEndPoint().x ), Iu2Mils( aLine->GetEndPoint().y ) ); m_out->Print( 0, "\n"); } @@ -2281,22 +2294,22 @@ void SCH_LEGACY_PLUGIN::saveText( SCH_TEXT* aText ) } m_out->Print( 0, "Text %s %-4d %-4d %-4d %-4d %s %d\n%s\n", textType, - aText->GetPosition().x, aText->GetPosition().y, + Iu2Mils( aText->GetPosition().x ), Iu2Mils( aText->GetPosition().y ), aText->GetLabelSpinStyle(), - aText->GetTextWidth(), - italics, aText->GetThickness(), TO_UTF8( text ) ); + Iu2Mils( aText->GetTextWidth() ), + italics, Iu2Mils( aText->GetThickness() ), TO_UTF8( text ) ); } else if( layer == LAYER_GLOBLABEL || layer == LAYER_HIERLABEL ) { textType = ( layer == LAYER_GLOBLABEL ) ? "GLabel" : "HLabel"; m_out->Print( 0, "Text %s %-4d %-4d %-4d %-4d %s %s %d\n%s\n", textType, - aText->GetPosition().x, aText->GetPosition().y, + Iu2Mils( aText->GetPosition().x ), Iu2Mils( aText->GetPosition().y ), aText->GetLabelSpinStyle(), - aText->GetTextWidth(), + Iu2Mils( aText->GetTextWidth() ), SheetLabelType[aText->GetShape()], italics, - aText->GetThickness(), TO_UTF8( text ) ); + Iu2Mils( aText->GetThickness() ), TO_UTF8( text ) ); } } @@ -2728,7 +2741,7 @@ LIB_PART* SCH_LEGACY_PLUGIN_CACHE::LoadPart( LINE_READER& aReader, int aMajorVer aReader.LineNumber(), pos ); pos += tmp.size() + 1; - part->SetPinNameOffset( (int)num ); + part->SetPinNameOffset( Mils2Iu( (int)num ) ); tmp = tokens.GetNextToken(); // Show pin numbers. @@ -2941,13 +2954,13 @@ void SCH_LEGACY_PLUGIN_CACHE::loadField( std::unique_ptr& aPart, wxPoint pos; - pos.x = parseInt( aReader, line, &line ); - pos.y = parseInt( aReader, line, &line ); + pos.x = Mils2Iu( parseInt( aReader, line, &line ) ); + pos.y = Mils2Iu( parseInt( aReader, line, &line ) ); field->SetPosition( pos ); wxSize textSize; - textSize.x = textSize.y = parseInt( aReader, line, &line ); + textSize.x = textSize.y = Mils2Iu( parseInt( aReader, line, &line ) ); field->SetTextSize( textSize ); char textOrient = parseChar( aReader, line, &line ); @@ -3126,11 +3139,11 @@ LIB_ARC* SCH_LEGACY_PLUGIN_CACHE::loadArc( std::unique_ptr& aPart, wxPoint center; - center.x = parseInt( aReader, line, &line ); - center.y = parseInt( aReader, line, &line ); + center.x = Mils2Iu( parseInt( aReader, line, &line ) ); + center.y = Mils2Iu( parseInt( aReader, line, &line ) ); arc->SetPosition( center ); - arc->SetRadius( parseInt( aReader, line, &line ) ); + arc->SetRadius( Mils2Iu( parseInt( aReader, line, &line ) ) ); int angle1 = parseInt( aReader, line, &line ); int angle2 = parseInt( aReader, line, &line ); @@ -3142,7 +3155,7 @@ LIB_ARC* SCH_LEGACY_PLUGIN_CACHE::loadArc( std::unique_ptr& aPart, arc->SetUnit( parseInt( aReader, line, &line ) ); arc->SetConvert( parseInt( aReader, line, &line ) ); - arc->SetWidth( parseInt( aReader, line, &line ) ); + arc->SetWidth( Mils2Iu( parseInt( aReader, line, &line ) ) ); // Old libraries (version <= 2.2) do not have always this FILL MODE param // when fill mode is no fill (default mode). @@ -3154,10 +3167,10 @@ LIB_ARC* SCH_LEGACY_PLUGIN_CACHE::loadArc( std::unique_ptr& aPart, { wxPoint arcStart, arcEnd; - arcStart.x = parseInt( aReader, line, &line ); - arcStart.y = parseInt( aReader, line, &line ); - arcEnd.x = parseInt( aReader, line, &line ); - arcEnd.y = parseInt( aReader, line, &line ); + arcStart.x = Mils2Iu( parseInt( aReader, line, &line ) ); + arcStart.y = Mils2Iu( parseInt( aReader, line, &line ) ); + arcEnd.x = Mils2Iu( parseInt( aReader, line, &line ) ); + arcEnd.y = Mils2Iu( parseInt( aReader, line, &line ) ); arc->SetStart( arcStart ); arc->SetEnd( arcEnd ); @@ -3192,14 +3205,14 @@ LIB_CIRCLE* SCH_LEGACY_PLUGIN_CACHE::loadCircle( std::unique_ptr& aPar wxPoint center; - center.x = parseInt( aReader, line, &line ); - center.y = parseInt( aReader, line, &line ); + center.x = Mils2Iu( parseInt( aReader, line, &line ) ); + center.y = Mils2Iu( parseInt( aReader, line, &line ) ); circle->SetPosition( center ); - circle->SetRadius( parseInt( aReader, line, &line ) ); + circle->SetRadius( Mils2Iu( parseInt( aReader, line, &line ) ) ); circle->SetUnit( parseInt( aReader, line, &line ) ); circle->SetConvert( parseInt( aReader, line, &line ) ); - circle->SetWidth( parseInt( aReader, line, &line ) ); + circle->SetWidth( Mils2Iu( parseInt( aReader, line, &line ) ) ); if( *line != 0 ) circle->SetFillMode( parseFillMode( aReader, line, &line ) ); @@ -3223,13 +3236,13 @@ LIB_TEXT* SCH_LEGACY_PLUGIN_CACHE::loadText( std::unique_ptr& aPart, wxPoint center; - center.x = parseInt( aReader, line, &line ); - center.y = parseInt( aReader, line, &line ); + center.x = Mils2Iu( parseInt( aReader, line, &line ) ); + center.y = Mils2Iu( parseInt( aReader, line, &line ) ); text->SetPosition( center ); wxSize size; - size.x = size.y = parseInt( aReader, line, &line ); + size.x = size.y = Mils2Iu( parseInt( aReader, line, &line ) ); text->SetTextSize( size ); text->SetVisible( !parseInt( aReader, line, &line ) ); text->SetUnit( parseInt( aReader, line, &line ) ); @@ -3312,19 +3325,19 @@ LIB_RECTANGLE* SCH_LEGACY_PLUGIN_CACHE::loadRectangle( std::unique_ptr wxPoint pos; - pos.x = parseInt( aReader, line, &line ); - pos.y = parseInt( aReader, line, &line ); + pos.x = Mils2Iu( parseInt( aReader, line, &line ) ); + pos.y = Mils2Iu( parseInt( aReader, line, &line ) ); rectangle->SetPosition( pos ); wxPoint end; - end.x = parseInt( aReader, line, &line ); - end.y = parseInt( aReader, line, &line ); + end.x = Mils2Iu( parseInt( aReader, line, &line ) ); + end.y = Mils2Iu( parseInt( aReader, line, &line ) ); rectangle->SetEnd( end ); rectangle->SetUnit( parseInt( aReader, line, &line ) ); rectangle->SetConvert( parseInt( aReader, line, &line ) ); - rectangle->SetWidth( parseInt( aReader, line, &line ) ); + rectangle->SetWidth( Mils2Iu( parseInt( aReader, line, &line ) ) ); if( *line != 0 ) rectangle->SetFillMode( parseFillMode( aReader, line, &line ) ); @@ -3365,7 +3378,7 @@ LIB_PIN* SCH_LEGACY_PLUGIN_CACHE::loadPin( std::unique_ptr& aPart, aReader.LineNumber(), pos ); pos += tmp.size() + 1; - position.x = (int) num; + position.x = Mils2Iu( (int) num ); tmp = tokens.GetNextToken(); @@ -3374,7 +3387,7 @@ LIB_PIN* SCH_LEGACY_PLUGIN_CACHE::loadPin( std::unique_ptr& aPart, aReader.LineNumber(), pos ); pos += tmp.size() + 1; - position.y = (int) num; + position.y = Mils2Iu( (int) num ); pin->m_position = position; tmp = tokens.GetNextToken(); @@ -3384,7 +3397,7 @@ LIB_PIN* SCH_LEGACY_PLUGIN_CACHE::loadPin( std::unique_ptr& aPart, aReader.LineNumber(), pos ); pos += tmp.size() + 1; - pin->m_length = (int) num; + pin->m_length = Mils2Iu( (int) num ); tmp = tokens.GetNextToken(); @@ -3403,7 +3416,7 @@ LIB_PIN* SCH_LEGACY_PLUGIN_CACHE::loadPin( std::unique_ptr& aPart, aReader.LineNumber(), pos ); pos += tmp.size() + 1; - pin->m_numTextSize = (int) num; + pin->m_numTextSize = Mils2Iu( (int) num ); tmp = tokens.GetNextToken(); @@ -3412,7 +3425,7 @@ LIB_PIN* SCH_LEGACY_PLUGIN_CACHE::loadPin( std::unique_ptr& aPart, aReader.LineNumber(), pos ); pos += tmp.size() + 1; - pin->m_nameTextSize = (int) num; + pin->m_nameTextSize = Mils2Iu( (int) num ); tmp = tokens.GetNextToken(); @@ -3527,15 +3540,15 @@ LIB_POLYLINE* SCH_LEGACY_PLUGIN_CACHE::loadPolyLine( std::unique_ptr& int points = parseInt( aReader, line, &line ); polyLine->SetUnit( parseInt( aReader, line, &line ) ); polyLine->SetConvert( parseInt( aReader, line, &line ) ); - polyLine->SetWidth( parseInt( aReader, line, &line ) ); + polyLine->SetWidth( Mils2Iu( parseInt( aReader, line, &line ) ) ); polyLine->Reserve( points ); wxPoint pt; for( int i = 0; i < points; i++ ) { - pt.x = parseInt( aReader, line, &line ); - pt.y = parseInt( aReader, line, &line ); + pt.x = Mils2Iu( parseInt( aReader, line, &line ) ); + pt.y = Mils2Iu( parseInt( aReader, line, &line ) ); polyLine->AddPoint( pt ); } @@ -3558,15 +3571,15 @@ LIB_BEZIER* SCH_LEGACY_PLUGIN_CACHE::loadBezier( std::unique_ptr& aPar int points = parseInt( aReader, line, &line ); bezier->SetUnit( parseInt( aReader, line, &line ) ); bezier->SetConvert( parseInt( aReader, line, &line ) ); - bezier->SetWidth( parseInt( aReader, line, &line ) ); + bezier->SetWidth( Mils2Iu( parseInt( aReader, line, &line ) ) ); wxPoint pt; bezier->Reserve( points ); for( int i = 0; i < points; i++ ) { - pt.x = parseInt( aReader, line, &line ); - pt.y = parseInt( aReader, line, &line ); + pt.x = Mils2Iu( parseInt( aReader, line, &line ) ); + pt.y = Mils2Iu( parseInt( aReader, line, &line ) ); bezier->AddPoint( pt ); } @@ -3679,7 +3692,7 @@ void SCH_LEGACY_PLUGIN_CACHE::SaveSymbol( LIB_PART* aSymbol, OUTPUTFORMATTER& aF } aFormatter.Print( 0, " %d %d %c %c %d %c %c\n", - 0, aSymbol->GetPinNameOffset(), + 0, Iu2Mils( aSymbol->GetPinNameOffset() ), aSymbol->ShowPinNumbers() ? 'Y' : 'N', aSymbol->ShowPinNames() ? 'Y' : 'N', aSymbol->GetUnitCount(), aSymbol->UnitsLocked() ? 'L' : 'F', @@ -3827,11 +3840,11 @@ void SCH_LEGACY_PLUGIN_CACHE::saveArc( LIB_ARC* aArc, x2 -= 3600; aFormatter.Print( 0, "A %d %d %d %d %d %d %d %d %c %d %d %d %d\n", - aArc->GetPosition().x, aArc->GetPosition().y, - aArc->GetRadius(), x1, x2, aArc->GetUnit(), aArc->GetConvert(), - aArc->GetWidth(), fill_tab[aArc->GetFillMode()], - aArc->GetStart().x, aArc->GetStart().y, - aArc->GetEnd().x, aArc->GetEnd().y ); + Iu2Mils( aArc->GetPosition().x ), Iu2Mils( aArc->GetPosition().y ), + Iu2Mils( aArc->GetRadius() ), x1, x2, aArc->GetUnit(), aArc->GetConvert(), + Iu2Mils( aArc->GetWidth() ), fill_tab[aArc->GetFillMode()], + Iu2Mils( aArc->GetStart().x ), Iu2Mils( aArc->GetStart().y ), + Iu2Mils( aArc->GetEnd().x ), Iu2Mils( aArc->GetEnd().y ) ); } @@ -3841,10 +3854,10 @@ void SCH_LEGACY_PLUGIN_CACHE::saveBezier( LIB_BEZIER* aBezier, wxCHECK_RET( aBezier && aBezier->Type() == LIB_BEZIER_T, "Invalid LIB_BEZIER object." ); aFormatter.Print( 0, "B %u %d %d %d", (unsigned)aBezier->GetPoints().size(), - aBezier->GetUnit(), aBezier->GetConvert(), aBezier->GetWidth() ); + aBezier->GetUnit(), aBezier->GetConvert(), Iu2Mils( aBezier->GetWidth() ) ); for( const auto& pt : aBezier->GetPoints() ) - aFormatter.Print( 0, " %d %d", pt.x, pt.y ); + aFormatter.Print( 0, " %d %d", Iu2Mils( pt.x ), Iu2Mils( pt.y ) ); aFormatter.Print( 0, " %c\n", fill_tab[aBezier->GetFillMode()] ); } @@ -3856,9 +3869,9 @@ void SCH_LEGACY_PLUGIN_CACHE::saveCircle( LIB_CIRCLE* aCircle, wxCHECK_RET( aCircle && aCircle->Type() == LIB_CIRCLE_T, "Invalid LIB_CIRCLE object." ); aFormatter.Print( 0, "C %d %d %d %d %d %d %c\n", - aCircle->GetPosition().x, aCircle->GetPosition().y, - aCircle->GetRadius(), aCircle->GetUnit(), aCircle->GetConvert(), - aCircle->GetWidth(), fill_tab[aCircle->GetFillMode()] ); + Iu2Mils( aCircle->GetPosition().x ), Iu2Mils( aCircle->GetPosition().y ), + Iu2Mils( aCircle->GetRadius() ), aCircle->GetUnit(), aCircle->GetConvert(), + Iu2Mils( aCircle->GetWidth() ), fill_tab[aCircle->GetFillMode()] ); } @@ -3888,7 +3901,8 @@ void SCH_LEGACY_PLUGIN_CACHE::saveField( LIB_FIELD* aField, aFormatter.Print( 0, "F%d %s %d %d %d %c %c %c %c%c%c", id, EscapedUTF8( text ).c_str(), // wraps in quotes - aField->GetTextPos().x, aField->GetTextPos().y, aField->GetTextWidth(), + Iu2Mils( aField->GetTextPos().x ), Iu2Mils( aField->GetTextPos().y ), + Iu2Mils( aField->GetTextWidth() ), aField->GetTextAngle() == 0 ? 'H' : 'V', aField->IsVisible() ? 'V' : 'I', hjustify, vjustify, @@ -3971,9 +3985,9 @@ void SCH_LEGACY_PLUGIN_CACHE::savePin( LIB_PIN* aPin, aFormatter.Print( 0, " %s %d %d %d %c %d %d %d %d %c", aPin->GetNumber().IsEmpty() ? "~" : TO_UTF8( aPin->GetNumber() ), - aPin->GetPosition().x, aPin->GetPosition().y, - (int) aPin->GetLength(), (int) aPin->GetOrientation(), - aPin->GetNumberTextSize(), aPin->GetNameTextSize(), + Iu2Mils( aPin->GetPosition().x ), Iu2Mils( aPin->GetPosition().y ), + Iu2Mils( (int) aPin->GetLength() ), (int) aPin->GetOrientation(), + Iu2Mils( aPin->GetNumberTextSize() ), Iu2Mils( aPin->GetNameTextSize() ), aPin->GetUnit(), aPin->GetConvert(), Etype ); if( aPin->GetShape() || !aPin->IsVisible() ) @@ -4037,11 +4051,11 @@ void SCH_LEGACY_PLUGIN_CACHE::savePolyLine( LIB_POLYLINE* aPolyLine, int ccount = aPolyLine->GetCornerCount(); aFormatter.Print( 0, "P %d %d %d %d", ccount, aPolyLine->GetUnit(), aPolyLine->GetConvert(), - aPolyLine->GetWidth() ); + Iu2Mils( aPolyLine->GetWidth() ) ); for( const auto& pt : aPolyLine->GetPolyPoints() ) { - aFormatter.Print( 0, " %d %d", pt.x, pt.y ); + aFormatter.Print( 0, " %d %d", Iu2Mils( pt.x ), Iu2Mils( pt.y ) ); } aFormatter.Print( 0, " %c\n", fill_tab[aPolyLine->GetFillMode()] ); @@ -4055,10 +4069,11 @@ void SCH_LEGACY_PLUGIN_CACHE::saveRectangle( LIB_RECTANGLE* aRectangle, "Invalid LIB_RECTANGLE object." ); aFormatter.Print( 0, "S %d %d %d %d %d %d %d %c\n", - aRectangle->GetPosition().x, aRectangle->GetPosition().y, - aRectangle->GetEnd().x, aRectangle->GetEnd().y, + Iu2Mils( aRectangle->GetPosition().x ), + Iu2Mils( aRectangle->GetPosition().y ), + Iu2Mils( aRectangle->GetEnd().x ), Iu2Mils( aRectangle->GetEnd().y ), aRectangle->GetUnit(), aRectangle->GetConvert(), - aRectangle->GetWidth(), fill_tab[aRectangle->GetFillMode()] ); + Iu2Mils( aRectangle->GetWidth() ), fill_tab[aRectangle->GetFillMode()] ); } @@ -4077,8 +4092,8 @@ void SCH_LEGACY_PLUGIN_CACHE::saveText( LIB_TEXT* aText, } aFormatter.Print( 0, "T %g %d %d %d %d %d %d %s", aText->GetTextAngle(), - aText->GetTextPos().x, aText->GetTextPos().y, - aText->GetTextWidth(), !aText->IsVisible(), + Iu2Mils( aText->GetTextPos().x ), Iu2Mils( aText->GetTextPos().y ), + Iu2Mils( aText->GetTextWidth() ), !aText->IsVisible(), aText->GetUnit(), aText->GetConvert(), TO_UTF8( text ) ); aFormatter.Print( 0, " %s %d", aText->IsItalic() ? "Italic" : "Normal", aText->IsBold() ); diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp index d9d07d9637..23801debd5 100644 --- a/eeschema/sch_no_connect.cpp +++ b/eeschema/sch_no_connect.cpp @@ -44,7 +44,7 @@ SCH_NO_CONNECT::SCH_NO_CONNECT( const wxPoint& pos ) : SCH_ITEM( NULL, SCH_NO_CONNECT_T ) { m_pos = pos; - m_size = 48; ///< No-connect symbol size. + m_size = Mils2iu( 48 ); ///< No-connect symbol size. SetLayer( LAYER_NOCONNECT ); } diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 7508801310..b9d0e6fe04 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -120,12 +120,12 @@ static LIB_PART* dummy() LIB_RECTANGLE* square = new LIB_RECTANGLE( part ); - square->MoveTo( wxPoint( -200, 200 ) ); - square->SetEndPosition( wxPoint( 200, -200 ) ); + square->MoveTo( wxPoint( Mils2iu( -200 ), Mils2iu( 200 ) ) ); + square->SetEndPosition( wxPoint( Mils2iu( 200 ), Mils2iu( -200 ) ) ); LIB_TEXT* text = new LIB_TEXT( part ); - text->SetTextSize( wxSize( 150, 150 ) ); + text->SetTextSize( wxSize( Mils2iu( 150 ), Mils2iu( 150 ) ) ); text->SetText( wxString( wxT( "??" ) ) ); part->AddDrawItem( square ); @@ -165,8 +165,8 @@ bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer ) m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER ); m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER ); m_gal->SetStrokeColor( COLOR4D( LIGHTRED ) ); - m_gal->SetLineWidth( 2 ); - m_gal->SetGlyphSize( VECTOR2D( 20, 20 ) ); + m_gal->SetLineWidth( Mils2ui( 2 ) ); + m_gal->SetGlyphSize( VECTOR2D( Mils2ui( 20 ), Mils2ui( 20 ) ) ); m_gal->StrokeText( conn->Name( true ), pos, 0.0 ); } @@ -896,8 +896,8 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer ) int insideOffset = textOffset; int outsideOffset = 10; float lineThickness = (float) GetDefaultLineThickness(); - float aboveOffset = PIN_TEXT_MARGIN + ( thickness[ABOVE] + lineThickness ) / 2.0; - float belowOffset = PIN_TEXT_MARGIN + ( thickness[BELOW] + lineThickness ) / 2.0; + float aboveOffset = Mils2iu( PIN_TEXT_MARGIN ) + ( thickness[ABOVE] + lineThickness ) / 2.0; + float belowOffset = Mils2iu( PIN_TEXT_MARGIN ) + ( thickness[BELOW] + lineThickness ) / 2.0; if( drawingShadows ) { @@ -1070,7 +1070,7 @@ void SCH_PAINTER::draw( LIB_BEZIER *aCurve, int aLayer ) // being moved. void SCH_PAINTER::drawDanglingSymbol( const wxPoint& aPos, bool aDrawingShadows ) { - wxPoint radius( DANGLING_SYMBOL_SIZE, DANGLING_SYMBOL_SIZE ); + wxPoint radius( Mils2iu( DANGLING_SYMBOL_SIZE ), Mils2iu( DANGLING_SYMBOL_SIZE ) ); m_gal->SetIsStroke( true ); m_gal->SetIsFill( false ); diff --git a/eeschema/sch_preview_panel.cpp b/eeschema/sch_preview_panel.cpp index 0b880bedb3..d5620810ef 100644 --- a/eeschema/sch_preview_panel.cpp +++ b/eeschema/sch_preview_panel.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2018-2019 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -67,7 +67,7 @@ SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL( wxWindow* aParentWindow, wxWindowID aWindo m_gal->SetGridColor( GetLayerColor( LAYER_SCHEMATIC_GRID ) ); m_gal->SetCursorColor( GetLayerColor( LAYER_SCHEMATIC_CURSOR ) ); - m_gal->SetGridSize( VECTOR2D( 50.0, 50.0 ) ); + m_gal->SetGridSize( VECTOR2D( Mils2iu( 50.0 ), Mils2iu( 50.0 ) ) ); m_viewControls->SetSnapping( true ); diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 0e7a6a2df7..26637275b0 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -4,7 +4,7 @@ * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck * Copyright (C) 2008 Wayne Stambaugh - * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -69,16 +69,36 @@ #include #define EESCHEMA_FILE_STAMP "EESchema" +#define ZOOM_FACTOR( x ) ( x * IU_PER_MILS ) + /* Default zoom values. Limited to these values to keep a decent size * to menus */ static double SchematicZoomList[] = { - 0.5, 0.7, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 8.0, 11.0, - 13.0, 16.0, 20.0, 26.0, 32.0, 48.0, 64.0, 80.0, 128.0 + ZOOM_FACTOR( 0.5 ), + ZOOM_FACTOR( 0.7 ), + ZOOM_FACTOR( 1.0 ), + ZOOM_FACTOR( 1.5 ), + ZOOM_FACTOR( 2.0 ), + ZOOM_FACTOR( 3.0 ), + ZOOM_FACTOR( 4.0 ), + ZOOM_FACTOR( 6.0 ), + ZOOM_FACTOR( 8.0 ), + ZOOM_FACTOR( 11.0 ), + ZOOM_FACTOR( 13.0 ), + ZOOM_FACTOR( 16.0 ), + ZOOM_FACTOR( 20.0 ), + ZOOM_FACTOR( 26.0 ), + ZOOM_FACTOR( 32.0 ), + ZOOM_FACTOR( 48.0 ), + ZOOM_FACTOR( 64.0 ), + ZOOM_FACTOR( 80.0 ), + ZOOM_FACTOR( 128.0 ) }; + /* Default grid sizes for the schematic editor. * Do NOT add others values (mainly grid values in mm), because they * can break the schematic: Because wires and pins are considered as @@ -92,13 +112,13 @@ static double SchematicZoomList[] = * 100mil grid, pin ends and origin must lie on grid nodes IEC-60617" */ static GRID_TYPE SchematicGridList[] = { - { ID_POPUP_GRID_LEVEL_100, wxRealPoint( 100, 100 ) }, - { ID_POPUP_GRID_LEVEL_50, wxRealPoint( 50, 50 ) }, - { ID_POPUP_GRID_LEVEL_25, wxRealPoint( 25, 25 ) }, - { ID_POPUP_GRID_LEVEL_10, wxRealPoint( 10, 10 ) }, - { ID_POPUP_GRID_LEVEL_5, wxRealPoint( 5, 5 ) }, - { ID_POPUP_GRID_LEVEL_2, wxRealPoint( 2, 2 ) }, - { ID_POPUP_GRID_LEVEL_1, wxRealPoint( 1, 1 ) }, + { ID_POPUP_GRID_LEVEL_100, wxRealPoint( Mils2iu( 100 ), Mils2iu( 100 ) ) }, + { ID_POPUP_GRID_LEVEL_50, wxRealPoint( Mils2iu( 50 ), Mils2iu( 50 ) ) }, + { ID_POPUP_GRID_LEVEL_25, wxRealPoint( Mils2iu( 25 ), Mils2iu( 25 ) ) }, + { ID_POPUP_GRID_LEVEL_10, wxRealPoint( Mils2iu( 10 ), Mils2iu( 10 ) ) }, + { ID_POPUP_GRID_LEVEL_5, wxRealPoint( Mils2iu( 5 ), Mils2iu( 5 ) ) }, + { ID_POPUP_GRID_LEVEL_2, wxRealPoint( Mils2iu( 2 ), Mils2iu( 2 ) ) }, + { ID_POPUP_GRID_LEVEL_1, wxRealPoint( Mils2iu( 1 ), Mils2iu( 1 ) ) }, }; @@ -118,7 +138,7 @@ SCH_SCREEN::SCH_SCREEN( KIWAY* aKiway ) : AddGrid( grid ); // Set the default grid size, now that the grid list is populated - SetGrid( wxRealPoint( 50, 50 ) ); + SetGrid( wxRealPoint( Mils2iu( 50 ), Mils2iu( 50 ) ) ); m_refCount = 0; @@ -133,9 +153,9 @@ SCH_SCREEN::~SCH_SCREEN() { ClearUndoRedoList(); - // Now delete items in draw list. We do that only if the list is not empty, - // because if the list was appended to another list (see SCH_SCREEN::Append( SCH_SCREEN* aScreen ) - // it is empty but as no longer the ownership (m_drawList.meOwner == false) of items, and calling + // Now delete items in draw list. We do that only if the list is not empty, because if the + // list was appended to another list (see SCH_SCREEN::Append( SCH_SCREEN* aScreen ) it is + // empty but as no longer the ownership (m_drawList.meOwner == false) of items, and calling // FreeDrawList() with m_drawList.meOwner == false will generate a debug alert in debug mode if( GetDrawItems() ) FreeDrawList(); @@ -894,9 +914,9 @@ bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxStri fpfield->SetTextSize( component->GetField( VALUE )->GetTextSize() ); if( fpfield->GetTextAngle() == 0.0 ) - fpfield->Offset( wxPoint( 0, 100 ) ); + fpfield->Offset( wxPoint( 0, Mils2iu( 100 ) ) ); else - fpfield->Offset( wxPoint( 100, 0 ) ); + fpfield->Offset( wxPoint( Mils2iu( 100 ), 0 ) ); } fpfield->SetText( aFootPrint ); diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 7710f2544c..035eae7d9f 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -151,7 +151,7 @@ wxPoint SCH_TEXT::GetSchematicTextOffset() const wxPoint text_offset; // add an offset to x (or y) position to aid readability of text on a wire or line - int thick_offset = TXT_MARGIN + ( GetPenSize() + GetDefaultLineThickness() ) / 2; + int thick_offset = Mils2iu( TXT_MARGIN ) + ( GetPenSize() + GetDefaultLineThickness() ) / 2; switch( GetLabelSpinStyle() ) { @@ -947,7 +947,8 @@ const EDA_RECT SCH_GLOBALLABEL::GetBoundingBox() const height = ( (GetTextHeight() * 15) / 10 ) + width + 2 * TXT_MARGIN; // text X size add height for triangular shapes(bidirectional) - length = LenSize( GetShownText(), width, GetTextMarkupFlags() ) + height + DANGLING_SYMBOL_SIZE; + length = LenSize( GetShownText(), width, GetTextMarkupFlags() ) + height + + Mils2iu( DANGLING_SYMBOL_SIZE ); switch( GetLabelSpinStyle() ) // respect orientation { @@ -955,7 +956,7 @@ const EDA_RECT SCH_GLOBALLABEL::GetBoundingBox() const case 0: // Horiz Normal Orientation (left justified) dx = -length; dy = height; - x += DANGLING_SYMBOL_SIZE; + x += Mils2iu( DANGLING_SYMBOL_SIZE ); y -= height / 2; break; @@ -963,13 +964,13 @@ const EDA_RECT SCH_GLOBALLABEL::GetBoundingBox() const dx = height; dy = -length; x -= height / 2; - y += DANGLING_SYMBOL_SIZE; + y += Mils2iu( DANGLING_SYMBOL_SIZE ); break; case 2: // Horiz Orientation - Right justified dx = length; dy = height; - x -= DANGLING_SYMBOL_SIZE; + x -= Mils2iu( DANGLING_SYMBOL_SIZE ); y -= height / 2; break; @@ -977,7 +978,7 @@ const EDA_RECT SCH_GLOBALLABEL::GetBoundingBox() const dx = height; dy = length; x -= height / 2; - y -= DANGLING_SYMBOL_SIZE; + y -= Mils2iu( DANGLING_SYMBOL_SIZE ); break; } @@ -1111,7 +1112,7 @@ const EDA_RECT SCH_HIERLABEL::GetBoundingBox() const height = GetTextHeight() + width + 2 * TXT_MARGIN; length = LenSize( GetShownText(), width, GetTextMarkupFlags() ) + height // add height for triangular shapes - + 2 * DANGLING_SYMBOL_SIZE; + + 2 * Mils2iu( DANGLING_SYMBOL_SIZE ); switch( GetLabelSpinStyle() ) { @@ -1119,7 +1120,7 @@ const EDA_RECT SCH_HIERLABEL::GetBoundingBox() const case 0: // Horiz Normal Orientation (left justified) dx = -length; dy = height; - x += DANGLING_SYMBOL_SIZE; + x += Mils2iu( DANGLING_SYMBOL_SIZE ); y -= height / 2; break; @@ -1127,13 +1128,13 @@ const EDA_RECT SCH_HIERLABEL::GetBoundingBox() const dx = height; dy = -length; x -= height / 2; - y += DANGLING_SYMBOL_SIZE; + y += Mils2iu( DANGLING_SYMBOL_SIZE ); break; case 2: // Horiz Orientation - Right justified dx = length; dy = height; - x -= DANGLING_SYMBOL_SIZE; + x -= Mils2iu( DANGLING_SYMBOL_SIZE ); y -= height / 2; break; @@ -1141,7 +1142,7 @@ const EDA_RECT SCH_HIERLABEL::GetBoundingBox() const dx = height; dy = length; x -= height / 2; - y -= DANGLING_SYMBOL_SIZE; + y -= Mils2iu( DANGLING_SYMBOL_SIZE ); break; } diff --git a/eeschema/sch_view.cpp b/eeschema/sch_view.cpp index 8d37336764..3d6b07a7db 100644 --- a/eeschema/sch_view.cpp +++ b/eeschema/sch_view.cpp @@ -56,7 +56,7 @@ SCH_VIEW::SCH_VIEW( bool aIsDynamic, SCH_BASE_FRAME* aFrame ) : // So we have to use a smaller value. // A full size = 3 * MAX_PAGE_SIZE_MILS size allows a wide margin // around the worksheet. - double max_size = MAX_PAGE_SIZE_MILS * IU_PER_MILS * 3.0; + double max_size = Mils2iu( MAX_PAGE_SIZE_MILS ) * 3.0; m_boundary.SetOrigin( -max_size/4, -max_size/4 ); m_boundary.SetSize( max_size, max_size ); @@ -83,11 +83,9 @@ void SCH_VIEW::SetScale( double aScale, VECTOR2D aAnchor ) void SCH_VIEW::ResizeSheetWorkingArea( SCH_SCREEN* aScreen ) { const PAGE_INFO& page_info = aScreen->GetPageSettings(); - // A full size = 3 * page size allows a wide margin around the worksheet. - // This is useful to have a large working area. - double max_size_x = page_info.GetWidthMils() * IU_PER_MILS * 2.0; - double max_size_y = page_info.GetHeightMils() * IU_PER_MILS * 2.0; - m_boundary.SetOrigin( -max_size_x /4, -max_size_y/4 ); + double max_size_x = page_info.GetWidthIU() * 3.0; + double max_size_y = page_info.GetHeightIU() * 3.0; + m_boundary.SetOrigin( -max_size_x/4, -max_size_y/4 ); m_boundary.SetSize( max_size_x, max_size_y ); } @@ -97,7 +95,8 @@ void SCH_VIEW::DisplaySheet( SCH_SCREEN *aScreen ) for( auto item = aScreen->GetDrawItems(); item; item = item->Next() ) Add( item ); - m_worksheet.reset( new KIGFX::WS_PROXY_VIEW_ITEM( 1, &aScreen->GetPageSettings(), + m_worksheet.reset( new KIGFX::WS_PROXY_VIEW_ITEM( static_cast< int >( IU_PER_MILS ), + &aScreen->GetPageSettings(), &aScreen->GetTitleBlock() ) ); m_worksheet->SetSheetNumber( aScreen->m_ScreenNumber ); m_worksheet->SetSheetCount( aScreen->m_NumberOfScreens ); @@ -222,6 +221,7 @@ void SCH_VIEW::HideWorksheet() // SetVisible( m_worksheet.get(), false ); } + void SCH_VIEW::HighlightItem( EDA_ITEM *aItem, LIB_PIN* aPin ) { if( aItem && aItem->Type() == SCH_COMPONENT_T && aPin ) diff --git a/eeschema/sch_view.h b/eeschema/sch_view.h index 0b313ea9b6..5a8b7c4187 100644 --- a/eeschema/sch_view.h +++ b/eeschema/sch_view.h @@ -38,8 +38,8 @@ class LIB_PART; class LIB_PIN; class SCH_BASE_FRAME; -// Eeschema uses mils as the internal units -constexpr double SCH_WORLD_UNIT = 0.001; +// Eeschema 100nm as the internal units +constexpr double SCH_WORLD_UNIT ( 1e-7 / 0.0254 ); static const LAYER_NUM SCH_LAYER_ORDER[] = { diff --git a/include/convert_to_biu.h b/include/convert_to_biu.h index b86f22ebd6..c54deb5fff 100644 --- a/include/convert_to_biu.h +++ b/include/convert_to_biu.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012-2016 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2016 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 1992-2019 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -52,6 +52,12 @@ inline int Mils2iu( int mils ) return int( x < 0 ? x - 0.5 : x + 0.5 ); } +constexpr inline double Iu2Mils( int iu ) +{ + double mils = iu / IU_PER_MILS; + + return static_cast< int >( mils < 0 ? mils - 0.5 : mils + 0.5 ); +} #elif defined (PL_EDITOR) constexpr double IU_PER_MM = 1e3; // internal units in micron (should be enough) constexpr double IU_PER_MILS = (IU_PER_MM * 0.0254); @@ -64,12 +70,20 @@ inline int Mils2iu( int mils ) } #elif defined (EESCHEMA) // Eeschema -constexpr double IU_PER_MILS = 1.0; -constexpr double IU_PER_MM = ( IU_PER_MILS / 0.0254 ); +constexpr double IU_PER_MM = 1e4; // Schematic internal units 1=100nm +constexpr double IU_PER_MILS = IU_PER_MM * 0.0254; constexpr inline int Mils2iu( int mils ) { - return mils; + double x = mils * IU_PER_MILS; + return int( x < 0 ? x - 0.5 : x + 0.5 ); +} + +constexpr inline int Iu2Mils( int iu ) +{ + double mils = iu / IU_PER_MILS; + + return static_cast< int >( mils < 0 ? mils - 0.5 : mils + 0.5 ); } #else // Here, we do not know the value of internal units: do not define @@ -94,10 +108,10 @@ constexpr inline double Iu2Millimeter( int iu ) } /// Convert mm to internal units (iu). -constexpr inline double Iu2Mils( int iu ) -{ - return iu / IU_PER_MILS; -} +// constexpr inline double Iu2Mils( int iu ) +// { +// return iu / IU_PER_MILS; +// } // The max error is the distance between the middle of a segment, and the circle // for circle/arc to segment approximation. diff --git a/qa/eeschema/CMakeLists.txt b/qa/eeschema/CMakeLists.txt index f3653c8b4b..04cd6551ce 100644 --- a/qa/eeschema/CMakeLists.txt +++ b/qa/eeschema/CMakeLists.txt @@ -41,6 +41,9 @@ add_executable( qa_eeschema # The main test entry points test_module.cpp + # Base internal units (1=100nm) testing. + test_sch_biu.cpp + test_eagle_plugin.cpp test_lib_part.cpp test_sch_pin.cpp diff --git a/qa/eeschema/test_sch_biu.cpp b/qa/eeschema/test_sch_biu.cpp new file mode 100644 index 0000000000..2ee30f4b56 --- /dev/null +++ b/qa/eeschema/test_sch_biu.cpp @@ -0,0 +1,62 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2019 KiCad Developers, see CHANGELOG.TXT for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/** + * @file test_sch_biu.cpp + * + * Test suite for schematic base internal units (1 = 100nm). + */ + +#include + +#include + + +class TEST_SCH_INTERNAL_UNITS +{ +public: + TEST_SCH_INTERNAL_UNITS() + { + } +}; + + +/** + * Declare the test suite + */ +BOOST_FIXTURE_TEST_SUITE( SchInternalUnits, TEST_SCH_INTERNAL_UNITS ) + + +BOOST_AUTO_TEST_CASE( ConvertToInternalUnits ) +{ + BOOST_CHECK_EQUAL( Millimeter2iu( 1.0 ), 10000 ); +} + + +BOOST_AUTO_TEST_CASE( ConvertFromInternalUnits ) +{ + BOOST_CHECK_EQUAL( static_cast< int >( Iu2Millimeter( 10000 ) ), 1 ); +} + + +BOOST_AUTO_TEST_SUITE_END()