kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #31874
Re: [PATCH] Fix for 3D model offset
Orson, Wayne,
I would agree. Please find attached a patch that implements "offset"
On Thu, Nov 23, 2017 at 7:05 PM, Maciej Sumiński <maciej.suminski@xxxxxxx>
wrote:
> I think the master branch already has enough new features to make its
> output incompatible with v4. 'Offset' approach seems the easiest and
> cleanest solution IMHO.
>
> Cheers,
> Orson
>
> On 11/22/2017 11:16 PM, Oliver Walters wrote:
> > I understand this will break "forwards compatibility" if opening a v5
> file
> > from v4. Sometimes such changes are unavoidable.
> >
> > On Thu, Nov 23, 2017 at 8:44 AM, easyw <easyw@xxxxxxxxxxxx> wrote:
> >
> >> This option is in fact a smooth transition for footprints...
> >> but it will break the readability of new boards by previous release of
> >> kicad... no way back to previous releases, even to be just read...
> >> Which is better then?
> >> Library stuff are quite delicate to be touched IMO...
> >>
> >> On 11/22/2017 10:23 PM, Oliver Walters wrote:
> >>
> >>> Wayne I still have an issue with silently breaking files. Using an
> >>> "offset" parameter (but reading "at" for compatibility) does not break
> >>> anyone's models and there is absolutely no confusion about which is mm
> and
> >>> which is inches. Incidentally I think "offset" is a better name, it
> implies
> >>> relative position rather than absolute (but that's neither here nor
> there).
> >>>
> >>> On Thu, Nov 23, 2017 at 7:55 AM, Marcos Chaparro <nitrousnrg@xxxxxxxxx
> >>> <mailto:nitrousnrg@xxxxxxxxx>> wrote:
> >>>
> >>> On Wed, Nov 22, 2017 at 11:59 AM, Wayne Stambaugh
> >>> <stambaughw@xxxxxxxxx <mailto:stambaughw@xxxxxxxxx>> wrote:
> >>>
> >>> Yes, it is a change that will break some users 3D models
> >>> but I think the long term benefit outweighs the short term
> >>> annoyance.
> >>>
> >>>
> >>> It will break most of my boards. I won't complain because I
> >>> appreciate the effort and I welcome *every* improvement, but be
> >>> prepared for some very rough comments out there.
> >>>
> >>> _______________________________________________
> >>> Mailing list: https://launchpad.net/~kicad-developers
> >>> <https://launchpad.net/~kicad-developers>
> >>> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> >>> <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
> >>> Unsubscribe : https://launchpad.net/~kicad-developers
> >>> <https://launchpad.net/~kicad-developers>
> >>> More help : https://help.launchpad.net/ListHelp
> >>> <https://help.launchpad.net/ListHelp>
> >>>
> >>>
> >>>
> >>>
> >>> _______________________________________________
> >>> Mailing list: https://launchpad.net/~kicad-developers
> >>> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> >>> Unsubscribe : https://launchpad.net/~kicad-developers
> >>> More help : https://help.launchpad.net/ListHelp
> >>>
> >>>
> >> _______________________________________________
> >> Mailing list: https://launchpad.net/~kicad-developers
> >> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> >> Unsubscribe : https://launchpad.net/~kicad-developers
> >> More help : https://help.launchpad.net/ListHelp
> >>
> >
> >
> >
> > _______________________________________________
> > Mailing list: https://launchpad.net/~kicad-developers
> > Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> > Unsubscribe : https://launchpad.net/~kicad-developers
> > More help : https://help.launchpad.net/ListHelp
> >
>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help : https://help.launchpad.net/ListHelp
>
>
From 0f3df37e066034c8f4dbe760ee8966730ade2b19 Mon Sep 17 00:00:00 2001
From: Oliver <oliver.henry.walters@xxxxxxxxx>
Date: Thu, 23 Nov 2017 21:21:48 +1100
Subject: [PATCH] CHANGE file format for 3D model offset
- Reverts behaviour of 3e71ed2421f5df433c11a554e0756f6898e25b06
- 3D model offset now explicitly written in mm, using "offset" tag
- Any read "at" tag is converted from inches to mm
- This will not break any 3D model offset when reading files
- It will however render files incompatible with old versions
---
pcbnew/kicad_plugin.cpp | 6 ++++--
pcbnew/kicad_plugin.h | 3 ++-
pcbnew/pcb_parser.cpp | 33 +++++++++++++++++++--------------
3 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp
index c4477ad..2c75f27 100644
--- a/pcbnew/kicad_plugin.cpp
+++ b/pcbnew/kicad_plugin.cpp
@@ -1140,8 +1140,10 @@ void PCB_IO::format( MODULE* aModule, int aNestLevel ) const
m_out->Print( aNestLevel+1, "(model %s\n",
m_out->Quotew( bs3D->m_Filename ).c_str() );
- // Model offset is in mm
- m_out->Print( aNestLevel+2, "(at (xyz %s %s %s))\n",
+ /* Write 3D model offset in mm
+ * 4.0.x wrote "at" which was actually in inches
+ */
+ m_out->Print( aNestLevel+2, "(offset (xyz %s %s %s))\n",
Double2Str( bs3D->m_Offset.x ).c_str(),
Double2Str( bs3D->m_Offset.y ).c_str(),
Double2Str( bs3D->m_Offset.z ).c_str() );
diff --git a/pcbnew/kicad_plugin.h b/pcbnew/kicad_plugin.h
index 87dc736..7423b4f 100644
--- a/pcbnew/kicad_plugin.h
+++ b/pcbnew/kicad_plugin.h
@@ -45,7 +45,8 @@ class NETINFO_MAPPING;
//#define SEXPR_BOARD_FILE_VERSION 20170123 // EDA_TEXT refactor, moved 'hide'
//#define SEXPR_BOARD_FILE_VERSION 20170920 // long pad names and custom pad shape
//#define SEXPR_BOARD_FILE_VERSION 20170922 // Keepout zones can exist on multiple layers
-#define SEXPR_BOARD_FILE_VERSION 20171114 // Save 3D model offset in mm, instead of inches
+//#define SEXPR_BOARD_FILE_VERSION 20171114 // Save 3D model offset in mm, instead of inches
+#define SEXPR_BOARD_FILE_VERSION 20171123 // 3D model offset written using "offset" parameter
#define CTL_STD_LAYER_NAMES (1 << 0) ///< Use English Standard layer names
#define CTL_OMIT_NETS (1 << 1) ///< Omit pads net names (useless in library)
diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp
index 494b91e..6532db7 100644
--- a/pcbnew/pcb_parser.cpp
+++ b/pcbnew/pcb_parser.cpp
@@ -360,25 +360,30 @@ MODULE_3D_SETTINGS* PCB_PARSER::parse3DModel()
Expecting( T_xyz );
/* Note:
- * Prior to SEXPR_BOARD_FILE_VERSION 20171114,
- * 3D model offset was read and written in inches
- *
- * Now, the offset is explicitly written in mm.
- * If a board is read with an older version,
- * the offset is converted from inches to mm
+ * Prior to KiCad v5, model offset was designated by "at",
+ * and the units were in inches.
+ * Now we use mm, but support reading of legacy files
*/
+ n3D->m_Offset.x = parseDouble( "x value" ) * 25.4f;
+ n3D->m_Offset.y = parseDouble( "y value" ) * 25.4f;
+ n3D->m_Offset.z = parseDouble( "z value" ) * 25.4f;
+ NeedRIGHT();
+ break;
+
+ case T_offset:
+ NeedLEFT();
+ token = NextTok();
+
+ if( token != T_xyz )
+ Expecting( T_xyz );
+
+ /*
+ * 3D model offset is in mm
+ */
n3D->m_Offset.x = parseDouble( "x value" );
n3D->m_Offset.y = parseDouble( "y value" );
n3D->m_Offset.z = parseDouble( "z value" );
-
- if(m_requiredVersion < 20171114L)
- {
- n3D->m_Offset.x *= 25.4f;
- n3D->m_Offset.y *= 25.4f;
- n3D->m_Offset.z *= 25.4f;
- }
-
NeedRIGHT();
break;
--
2.7.4
Follow ups
References
-
[PATCH] Fix for 3D model offset
From: Oliver Walters, 2017-11-08
-
Re: [PATCH] Fix for 3D model offset
From: Oliver Walters, 2017-11-14
-
Re: [PATCH] Fix for 3D model offset
From: easyw, 2017-11-15
-
Re: [PATCH] Fix for 3D model offset
From: Maciej Suminski, 2017-11-15
-
Re: [PATCH] Fix for 3D model offset
From: easyw, 2017-11-21
-
Re: [PATCH] Fix for 3D model offset
From: Oliver Walters, 2017-11-21
-
Re: [PATCH] Fix for 3D model offset
From: Wayne Stambaugh, 2017-11-22
-
Re: [PATCH] Fix for 3D model offset
From: easyw, 2017-11-22
-
Re: [PATCH] Fix for 3D model offset
From: Oliver Walters, 2017-11-22
-
Re: [PATCH] Fix for 3D model offset
From: Wayne Stambaugh, 2017-11-22
-
Re: [PATCH] Fix for 3D model offset
From: José Ignacio, 2017-11-22
-
Re: [PATCH] Fix for 3D model offset
From: Wayne Stambaugh, 2017-11-22
-
Re: [PATCH] Fix for 3D model offset
From: Marcos Chaparro, 2017-11-22
-
Re: [PATCH] Fix for 3D model offset
From: Oliver Walters, 2017-11-22
-
Re: [PATCH] Fix for 3D model offset
From: easyw, 2017-11-22
-
Re: [PATCH] Fix for 3D model offset
From: Oliver Walters, 2017-11-22
-
Re: [PATCH] Fix for 3D model offset
From: Maciej Sumiński, 2017-11-23