diff --git a/include/eda_text.h b/include/eda_text.h index d72e21b6ea..f82609da5c 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -134,7 +134,10 @@ public: int GetThickness() const { return m_Thickness; }; void SetOrientation( double aOrientation ); + void SetOrientationDegrees( double aOrientation ) { SetOrientation( aOrientation*10.0 ); } double GetOrientation() const { return m_Orient; } + double GetOrientationDegrees() const { return m_Orient/10.0; } + double GetOrientationRadians() const { return m_Orient*M_PI/1800; } void SetItalic( bool isItalic ) { m_Italic = isItalic; } bool IsItalic() const { return m_Italic; } diff --git a/include/trigo.h b/include/trigo.h index 4b3a5ad6af..838ee43307 100644 --- a/include/trigo.h +++ b/include/trigo.h @@ -208,6 +208,7 @@ template inline void NORMALIZE_ANGLE_360( T &Angle ) } /// Normalize angle to be in the 0.0 .. 360.0 range: +/// angle is in 1/10 degees template inline void NORMALIZE_ANGLE_POS( T &Angle ) { while( Angle < 0 ) @@ -216,6 +217,16 @@ template inline void NORMALIZE_ANGLE_POS( T &Angle ) Angle -= 3600; } +/// Normalize angle to be in the 0.0 .. 360.0 range: +/// angle is in degrees +inline void NORMALIZE_ANGLE_DEGREES_POS( double &Angle ) +{ + while( Angle < 0 ) + Angle += 360.0; + while( Angle >= 360.0 ) + Angle -= 360.0; +} + /// Add two angles (keeping the result normalized). T2 is here // because most of the time it's an int (and templates don't promote in // that way) diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index b0a9824b14..8c518a4425 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -576,7 +576,9 @@ void MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) // display schematic path aList.push_back( MSG_PANEL_ITEM( _( "Netlist Path" ), m_Path, BROWN ) ); - aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), RED ) ); + // display the board side placement + aList.push_back( MSG_PANEL_ITEM( _( "Board Side" ), + IsFlipped()? _( "Back (Flipped)" ) : _( "Front" ), RED ) ); EDA_ITEM* PtStruct = m_Pads; nbpad = 0; @@ -600,8 +602,8 @@ void MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) aList.push_back( MSG_PANEL_ITEM( _( "Status" ), msg, MAGENTA ) ); - msg.Printf( wxT( "%.1f" ), m_Orient / 10.0 ); - aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, BROWN ) ); + msg.Printf( wxT( "%.1f" ), GetOrientationDegrees() ); + aList.push_back( MSG_PANEL_ITEM( _( "Rotation" ), msg, BROWN ) ); // Controls on right side of the dialog switch( m_Attributs & 255 ) diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index fedc62eaa0..e0b269bbf5 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -161,7 +161,10 @@ public: const wxPoint& GetPosition() const { return m_Pos; } // was overload void SetOrientation( double newangle ); + void SetOrientationDegrees( double aOrientation ) { SetOrientation( aOrientation*10.0 ); } double GetOrientation() const { return m_Orient; } + double GetOrientationDegrees() const { return m_Orient/10.0; } + double GetOrientationRadians() const { return m_Orient*M_PI/1800; } const FPID& GetFPID() const { return m_fpid; } void SetFPID( const FPID& aFPID ) { m_fpid = aFPID; } diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index 83e41a1c60..89ebfb1ab9 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -676,14 +676,14 @@ void D_PAD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM>& aList ) aList.push_back( MSG_PANEL_ITEM( _( "Drill X / Y" ), Line, RED ) ); } - double module_orient = module ? module->GetOrientation() : 0; + double module_orient_degrees = module ? module->GetOrientationDegrees() : 0; - if( module_orient ) + if( module_orient_degrees != 0.0 ) Line.Printf( wxT( "%3.1f(+%3.1f)" ), - ( m_Orient - module_orient ) / 10.0, - module_orient / 10.0 ); + GetOrientationDegrees() - module_orient_degrees, + module_orient_degrees ); else - Line.Printf( wxT( "%3.1f" ), m_Orient / 10.0 ); + Line.Printf( wxT( "%3.1f" ), GetOrientationDegrees() ); aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), Line, LIGHTBLUE ) ); diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 19d23eb874..5aa2d14ef4 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -198,11 +198,18 @@ public: */ void SetOrientation( double aAngle ); + /** + * Set orientation in degrees + */ + void SetOrientationDegrees( double aOrientation ) { SetOrientation( aOrientation*10.0 ); } + /** * Function GetOrientation * returns the rotation angle of the pad in tenths of degrees, but soon degrees. */ double GetOrientation() const { return m_Orient; } + double GetOrientationDegrees() const { return m_Orient/10.0; } + double GetOrientationRadians() const { return m_Orient*M_PI/1800; } void SetDrillShape( PAD_DRILL_SHAPE_T aDrillShape ) { m_drillShape = aDrillShape; } diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index 701e9445c2..adb1f302c3 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -316,7 +316,7 @@ double TEXTE_MODULE::GetDrawRotation() const if( module ) rotation += module->GetOrientation(); - // For angle = -90 .. 90 deg + // Keep angle between -90 .. 90 deg. Otherwise the text is not easy to read while( rotation > 900 ) rotation -= 1800; @@ -368,7 +368,7 @@ void TEXTE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), msg, DARKGREEN ) ); - msg.Printf( wxT( "%.1f" ), m_Orient / 10.0 ); + msg.Printf( wxT( "%.1f" ), GetOrientationDegrees() ); aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) ); msg = ::CoordinateToString( m_Thickness ); diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h index fbc5f50a2e..cb6b0470c1 100644 --- a/pcbnew/class_text_mod.h +++ b/pcbnew/class_text_mod.h @@ -121,6 +121,7 @@ public: * the footprint rotation is taken in account */ double GetDrawRotation() const; + double GetDrawRotationRadians() const { return GetDrawRotation() * M_PI/1800; } // Virtual function const EDA_RECT GetBoundingBox() const; diff --git a/pcbnew/dialogs/dialog_select_pretty_lib_base.cpp b/pcbnew/dialogs/dialog_select_pretty_lib_base.cpp index 17b70a1eb0..67df86056a 100644 --- a/pcbnew/dialogs/dialog_select_pretty_lib_base.cpp +++ b/pcbnew/dialogs/dialog_select_pretty_lib_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 17 2015) +// C++ code generated with wxFormBuilder (version May 2 2016) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -16,11 +16,11 @@ DIALOG_SELECT_PRETTY_LIB_BASE::DIALOG_SELECT_PRETTY_LIB_BASE( wxWindow* parent, wxBoxSizer* bSizerMain; bSizerMain = new wxBoxSizer( wxVERTICAL ); - m_staticText = new wxStaticText( this, wxID_ANY, _("The footprint library is a folder with a name ending with .pretty\nFootprints are .kicad_mod files inside this folder."), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText->Wrap( -1 ); - m_staticText->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) ); + m_messageInfo = new wxStaticText( this, wxID_ANY, _("The footprint library is a folder with a name ending with .pretty\nFootprints are .kicad_mod files inside this folder."), wxDefaultPosition, wxDefaultSize, 0 ); + m_messageInfo->Wrap( -1 ); + m_messageInfo->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) ); - bSizerMain->Add( m_staticText, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + bSizerMain->Add( m_messageInfo, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); m_staticText3 = new wxStaticText( this, wxID_ANY, _("Path base:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText3->Wrap( -1 ); @@ -56,7 +56,6 @@ DIALOG_SELECT_PRETTY_LIB_BASE::DIALOG_SELECT_PRETTY_LIB_BASE( wxWindow* parent, this->SetSizer( bSizerMain ); this->Layout(); - bSizerMain->Fit( this ); this->Centre( wxBOTH ); diff --git a/pcbnew/dialogs/dialog_select_pretty_lib_base.fbp b/pcbnew/dialogs/dialog_select_pretty_lib_base.fbp index 34d665b9e0..3cc9bb4c4f 100644 --- a/pcbnew/dialogs/dialog_select_pretty_lib_base.fbp +++ b/pcbnew/dialogs/dialog_select_pretty_lib_base.fbp @@ -44,7 +44,7 @@ -1,-1 DIALOG_SELECT_PRETTY_LIB_BASE - -1,-1 + 401,206 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Select Footprint Library Folder @@ -133,7 +133,7 @@ 0 1 - m_staticText + m_messageInfo 1 @@ -474,7 +474,7 @@ 0 - + 0 0 diff --git a/pcbnew/dialogs/dialog_select_pretty_lib_base.h b/pcbnew/dialogs/dialog_select_pretty_lib_base.h index 9c5893db1d..f2430ca91a 100644 --- a/pcbnew/dialogs/dialog_select_pretty_lib_base.h +++ b/pcbnew/dialogs/dialog_select_pretty_lib_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 17 2015) +// C++ code generated with wxFormBuilder (version May 2 2016) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -38,7 +38,7 @@ class DIALOG_SELECT_PRETTY_LIB_BASE : public DIALOG_SHIM private: protected: - wxStaticText* m_staticText; + wxStaticText* m_messageInfo; wxStaticText* m_staticText3; wxDirPickerCtrl* m_dirCtrl; wxBoxSizer* m_SizerNewLibName; @@ -56,7 +56,7 @@ class DIALOG_SELECT_PRETTY_LIB_BASE : public DIALOG_SHIM public: - DIALOG_SELECT_PRETTY_LIB_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Select Footprint Library Folder"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_SELECT_PRETTY_LIB_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Select Footprint Library Folder"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 401,206 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_SELECT_PRETTY_LIB_BASE(); }; diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index c0fb9f2b6a..271e8833b4 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -565,7 +565,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) m_gal->Save(); m_gal->Translate( VECTOR2D( aPad->GetPosition() ) ); - m_gal->Rotate( -aPad->GetOrientation() * M_PI / 1800.0 ); + m_gal->Rotate( -aPad->GetOrientationRadians() ); // Choose drawing settings depending on if we are drawing a pad itself or a hole VECTOR2D size; @@ -771,7 +771,7 @@ void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment, int aLayer ) if( module ) { m_gal->Translate( module->GetPosition() ); - m_gal->Rotate( -module->GetOrientation() * M_PI / 1800.0 ); + m_gal->Rotate( -module->GetOrientationRadians() ); } else { @@ -812,7 +812,6 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer ) const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() ); VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y ); - double orientation = aText->GetOrientation() * M_PI / 1800.0; if( m_pcbSettings.m_sketchMode[aLayer] ) { @@ -829,7 +828,7 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer ) m_gal->SetIsStroke( true ); m_gal->SetStrokeColor( color ); m_gal->SetTextAttributes( aText ); - m_gal->StrokeText( shownText, position, orientation ); + m_gal->StrokeText( shownText, position, aText->GetOrientationRadians() ); } @@ -841,7 +840,6 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer ) const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer ); VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y ); - double orientation = aText->GetDrawRotation() * M_PI / 1800.0; if( m_pcbSettings.m_sketchMode[aLayer] ) { @@ -858,7 +856,7 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer ) m_gal->SetIsStroke( true ); m_gal->SetStrokeColor( color ); m_gal->SetTextAttributes( aText ); - m_gal->StrokeText( shownText, position, orientation ); + m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians() ); // Draw the umbilical line if( aText->IsSelected() && aText->GetType() != TEXTE_MODULE::TEXT_is_DIVERS ) @@ -989,11 +987,10 @@ void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer ) // Draw text TEXTE_PCB& text = aDimension->Text(); VECTOR2D position( text.GetTextPosition().x, text.GetTextPosition().y ); - double orientation = text.GetOrientation() * M_PI / 1800.0; m_gal->SetLineWidth( text.GetThickness() ); m_gal->SetTextAttributes( &text ); - m_gal->StrokeText( text.GetShownText(), position, orientation ); + m_gal->StrokeText( text.GetShownText(), position, text.GetOrientationRadians() ); } diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp index 911a23c831..50dd0323ec 100644 --- a/pcbnew/specctra_export.cpp +++ b/pcbnew/specctra_export.cpp @@ -741,13 +741,9 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule ) pin->padstack_id = padstack->padstack_id; - int angle = pad->GetOrientation() - aModule->GetOrientation(); // tenths of degrees - - if( angle ) - { - NORMALIZE_ANGLE_POS( angle ); - pin->SetRotation( angle / 10.0 ); - } + double angle = pad->GetOrientationDegrees() - aModule->GetOrientationDegrees(); + NORMALIZE_ANGLE_DEGREES_POS( angle ); + pin->SetRotation( angle ); wxPoint pos( pad->GetPos0() ); @@ -1865,7 +1861,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) comp->places.push_back( place ); - place->SetRotation( module->GetOrientation()/10.0 ); + place->SetRotation( module->GetOrientationDegrees() ); place->SetVertex( mapPt( module->GetPosition() ) ); place->component_id = componentId; place->part_number = TO_UTF8( module->GetValue() ); @@ -1873,9 +1869,9 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) // module is flipped from bottom side, set side to T_back if( module->GetFlag() ) { - int angle = 1800 - module->GetOrientation(); - NORMALIZE_ANGLE_POS( angle ); - place->SetRotation( angle / 10.0 ); + double angle = 180.0 - module->GetOrientationDegrees(); + NORMALIZE_ANGLE_DEGREES_POS( angle ); + place->SetRotation( angle ); place->side = T_back; }