Commit c7e7014b authored by dickelbeck's avatar dickelbeck

module flip reverting on exception

parent cb138403
......@@ -3578,6 +3578,8 @@ class SPECCTRA_DB : public OUTPUTFORMATTER
std::string quote_char;
bool modulesAreFlipped;
STRINGFORMATTER sf;
STRINGS layerIds; ///< indexed by PCB layer number
......@@ -3822,6 +3824,11 @@ class SPECCTRA_DB : public OUTPUTFORMATTER
nets.clear();
}
/**
* Function flipMODULEs
* flips the modules which are on the back side of the board to the front.
*/
void flipMODULEs( BOARD* aBoard );
//-----<FromSESSION>-----------------------------------------------------
......@@ -3850,6 +3857,7 @@ public:
session = 0;
fp = 0;
quote_char += '"';
modulesAreFlipped = false;
}
virtual ~SPECCTRA_DB()
......@@ -3957,7 +3965,6 @@ public:
*/
void FromBOARD( BOARD* aBoard ) throw( IOError );
/**
* Function FromSESSION
* adds the entire SESSION info to a BOARD but does not write it out. The
......@@ -3968,7 +3975,6 @@ public:
*/
void FromSESSION( BOARD* aBoard ) throw( IOError );
/**
* Function ExportSESSION
* writes the internal SESSION instance out as a SPECTRA DSN format file.
......@@ -3976,6 +3982,12 @@ public:
* @param aFilename The file to save to.
*/
void ExportSESSION( wxString aFilename );
/**
* Function RevertMODULEs
* flips the modules which were on the back side of the board back to the back.
*/
void RevertMODULEs( BOARD* aBoard );
};
......
......@@ -97,6 +97,11 @@ void WinEDA_PcbFrame::ExportToSpecctra( wxCommandEvent& event )
setlocale( LC_NUMERIC, "" ); // revert to the current locale
// this is called in FromBOARD() too, but if it throws an exception, that call
// does not happen, so call it again just in case here.
db.RevertMODULEs( m_Pcb );
// The two calls below to BOARD::Change_Side_Module(), both set the
// modified flag, yet their actions cancel each other out, so it should
// be ok to clear the modify flag.
......@@ -727,15 +732,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IOError )
// DSN Images (=Kicad MODULES and pads) must be presented from the
// top view. So we temporarily flip any modules which are on the back
// side of the board to the front, and record this in the MODULE's flag field.
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
{
module->flag = 0;
if( module->GetLayer() == COPPER_LAYER_N )
{
aBoard->Change_Side_Module( module, NULL );
module->flag = 1;
}
}
flipMODULEs( aBoard );
//-----<layer_descriptor>-----------------------------------------------
{
......@@ -1220,7 +1217,32 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IOError )
}
//-----<restore MODULEs>------------------------------------------------
//-----<flip modules back>----------------------------------------------
RevertMODULEs( aBoard );
}
void SPECCTRA_DB::flipMODULEs( BOARD* aBoard )
{
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
{
module->flag = 0;
if( module->GetLayer() == COPPER_LAYER_N )
{
aBoard->Change_Side_Module( module, NULL );
module->flag = 1;
}
}
modulesAreFlipped = true;
}
void SPECCTRA_DB::RevertMODULEs( BOARD* aBoard )
{
if( !modulesAreFlipped )
return;
// DSN Images (=Kicad MODULES and pads) must be presented from the
// top view. Restore those that were flipped.
......@@ -1232,6 +1254,8 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IOError )
module->flag = 0;
}
}
modulesAreFlipped = false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment