void TEXTE_MODULE::Flip( const wxPoint& aCentre ) { // flipping the footprint is relative to the X axis MIRROR( m_Pos.y, aCentre.y ); NEGATE_AND_NORMALIZE_ANGLE_POS( m_Orient ); SetLayer( FlipLayer( GetLayer() ) ); m_Mirror = IsBackLayer( GetLayer() ); SetLocalCoord(); }
void TEXTE_MODULE::Mirror( const wxPoint& aCentre, bool aMirrorAroundXAxis ) { // Used in modedit, to transform the footprint // the mirror is around the Y axis or X axis if aMirrorAroundXAxis = true // the position is mirrored, but the text itself is not mirrored if( aMirrorAroundXAxis ) MIRROR( m_Pos.y, aCentre.y ); else MIRROR( m_Pos.x, aCentre.x ); NEGATE_AND_NORMALIZE_ANGLE_POS( m_Orient ); SetLocalCoord(); }
void MODULE::Flip( const wxPoint& aCentre ) { TEXTE_MODULE* text; // Move module to its final position: wxPoint finalPos = m_Pos; finalPos.y = aCentre.y - ( finalPos.y - aCentre.y ); /// Mirror the Y position SetPosition( finalPos ); // Flip layer SetLayer( FlipLayer( GetLayer() ) ); // Reverse mirror orientation. NEGATE( m_Orient ); NORMALIZE_ANGLE_POS( m_Orient ); // Mirror pads to other side of board about the x axis, i.e. vertically. for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) pad->Flip( m_Pos ); // Mirror reference. text = m_Reference; text->m_Pos.y -= m_Pos.y; NEGATE( text->m_Pos.y ); text->m_Pos.y += m_Pos.y; NEGATE(text->m_Pos0.y); NEGATE_AND_NORMALIZE_ANGLE_POS( text->m_Orient ); text->SetLayer( FlipLayer( text->GetLayer() ) ); text->m_Mirror = IsBackLayer( GetLayer() ); // Mirror value. text = m_Value; text->m_Pos.y -= m_Pos.y; NEGATE( text->m_Pos.y ); text->m_Pos.y += m_Pos.y; NEGATE( text->m_Pos0.y ); NEGATE_AND_NORMALIZE_ANGLE_POS( text->m_Orient ); text->SetLayer( FlipLayer( text->GetLayer() ) ); text->m_Mirror = IsBackLayer( GetLayer() ); // Reverse mirror module graphics and texts. for( EDA_ITEM* item = m_Drawings; item; item = item->Next() ) { switch( item->Type() ) { case PCB_MODULE_EDGE_T: { EDGE_MODULE* em = (EDGE_MODULE*) item; wxPoint s = em->GetStart(); s.y -= m_Pos.y; s.y = -s.y; s.y += m_Pos.y; em->SetStart( s ); wxPoint e = em->GetEnd(); e.y -= m_Pos.y; e.y = -e.y; e.y += m_Pos.y; em->SetEnd( e ); NEGATE( em->m_Start0.y ); NEGATE( em->m_End0.y ); if( em->GetShape() == S_ARC ) { em->SetAngle( -em->GetAngle() ); } em->SetLayer( FlipLayer( em->GetLayer() ) ); } break; case PCB_MODULE_TEXT_T: text = (TEXTE_MODULE*) item; text->m_Pos.y -= m_Pos.y; NEGATE( text->m_Pos.y ); text->m_Pos.y += m_Pos.y; NEGATE( text->m_Pos0.y ); NEGATE_AND_NORMALIZE_ANGLE_POS( text->m_Orient ); text->SetLayer( FlipLayer( text->GetLayer() ) ); text->m_Mirror = IsBackLayer( GetLayer() ); break; default: wxMessageBox( wxT( "MODULE::Flip() error: Unknown Draw Type" ) ); break; } } CalculateBoundingBox(); }
/* Creates the section $COMPONENTS (Footprints placement) * Bottom side components are difficult to handle: shapes must be mirrored or * flipped, silk layers need to be handled correctly and so on. Also it seems * that *noone* follows the specs... */ static void CreateComponentsSection( FILE* aFile, BOARD* aPcb ) { fputs( "$COMPONENTS\n", aFile ); int cu_count = aPcb->GetCopperLayerCount(); for( MODULE* module = aPcb->m_Modules; module; module = module->Next() ) { const char* mirror; const char* flip; double fp_orient = module->GetOrientation(); if( module->GetFlag() ) { mirror = "0"; flip = "FLIP"; NEGATE_AND_NORMALIZE_ANGLE_POS( fp_orient ); } else { mirror = "0"; flip = "0"; } fprintf( aFile, "\nCOMPONENT %s\n", TO_UTF8( module->GetReference() ) ); fprintf( aFile, "DEVICE %s_%s\n", TO_UTF8( module->GetReference() ), TO_UTF8( module->GetValue() ) ); fprintf( aFile, "PLACE %g %g\n", MapXTo( module->GetPosition().x ), MapYTo( module->GetPosition().y ) ); fprintf( aFile, "LAYER %s\n", (module->GetFlag()) ? "BOTTOM" : "TOP" ); fprintf( aFile, "ROTATION %g\n", fp_orient / 10.0 ); fprintf( aFile, "SHAPE %s %s %s\n", TO_UTF8( module->GetReference() ), mirror, flip ); // Text on silk layer: RefDes and value (are they actually useful?) TEXTE_MODULE *textmod = &module->Reference(); for( int ii = 0; ii < 2; ii++ ) { double txt_orient = textmod->GetOrientation(); std::string layer = GenCADLayerName( cu_count, module->GetFlag() ? B_SilkS : F_SilkS ); fprintf( aFile, "TEXT %g %g %g %g %s %s \"%s\"", textmod->GetPos0().x / SCALE_FACTOR, -textmod->GetPos0().y / SCALE_FACTOR, textmod->GetSize().x / SCALE_FACTOR, txt_orient / 10.0, mirror, layer.c_str(), TO_UTF8( textmod->GetText() ) ); // Please note, the width is approx fprintf( aFile, " 0 0 %g %g\n", ( textmod->GetSize().x * textmod->GetLength() ) / SCALE_FACTOR, textmod->GetSize().y / SCALE_FACTOR ); textmod = &module->Value(); // Dirty trick for the second iteration } // The SHEET is a 'generic description' for referencing the component fprintf( aFile, "SHEET \"RefDes: %s, Value: %s\"\n", TO_UTF8( module->GetReference() ), TO_UTF8( module->GetValue() ) ); } fputs( "$ENDCOMPONENTS\n\n", aFile ); }
void WinEDA_BasePcbFrame::Change_Side_Module(MODULE * Module, wxDC * DC) /**********************************************************************/ /* Change de cote un composant : il y a inversion MIROIR autour de l'axe X Le changement n'est fait que si la couche est - CUIVRE ou CMP Si DC == NULL, il n'y a pas de redessin du composant et du chevelu */ { D_PAD* pt_pad ; TEXTE_MODULE* pt_texte; EDGE_MODULE * pt_edgmod ; EDA_BaseStruct * PtStruct; if ( Module == NULL ) return; if( (Module->m_Layer != CMP_N) && (Module->m_Layer != CUIVRE_N) ) return; m_CurrentScreen->SetModify(); if ( ! (Module->m_Flags & IS_MOVED) ) { m_Pcb->m_Status_Pcb &= ~( LISTE_CHEVELU_OK | CONNEXION_OK); if ( DC ) Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR); /* Effacement chevelu general si necessaire */ if ( DC && g_Show_Ratsnest) DrawGeneralRatsnest(DC); /* Init des variables utilisees dans la routine Dessine_Drag_segment() */ g_Offset_Module.x = 0; g_Offset_Module.y = 0; } else // Module en deplacement { /* efface empreinte ( vue en contours) si elle a ete deja dessinee */ if ( DC ) { DrawModuleOutlines(DrawPanel, DC, Module); Dessine_Segments_Dragges(DrawPanel, DC); } } /* mise a jour du Flag de l'empreinte et des couches des contours et textes */ Module->m_Layer = ChangeSideNumLayer(Module->m_Layer); /* Inversion miroir de l'orientation */ Module->m_Orient = - Module->m_Orient; NORMALIZE_ANGLE_POS(Module->m_Orient); /* Inversion miroir + layers des pastilles */ pt_pad = Module->m_Pads; for ( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) { pt_pad->m_Pos.y -= Module->m_Pos.y ; pt_pad->m_Pos.y = -pt_pad->m_Pos.y; pt_pad->m_Pos.y += Module->m_Pos.y; pt_pad->m_Pos0.y = - pt_pad->m_Pos0.y; pt_pad->m_Offset.y = -pt_pad->m_Offset.y; pt_pad->m_DeltaSize.y = -pt_pad->m_DeltaSize.y; NEGATE_AND_NORMALIZE_ANGLE_POS(pt_pad->m_Orient); /* change cote pour pastilles surfaciques */ pt_pad->m_Masque_Layer = ChangeSideMaskLayer(pt_pad->m_Masque_Layer); } /* Inversion miroir de la Reference et mise en miroir : */ pt_texte = Module->m_Reference; pt_texte->m_Pos.y -= Module->m_Pos.y; pt_texte->m_Pos.y = -pt_texte->m_Pos.y; pt_texte->m_Pos.y += Module->m_Pos.y; pt_texte->m_Pos0.y = pt_texte->m_Pos0.y; pt_texte->m_Miroir = 1 ; NEGATE_AND_NORMALIZE_ANGLE_POS(pt_texte->m_Orient); pt_texte->m_Layer = Module->m_Layer; pt_texte->m_Layer = ChangeSideNumLayer(pt_texte->m_Layer); if( Module->m_Layer == CUIVRE_N) pt_texte->m_Layer = SILKSCREEN_N_CU; if( Module->m_Layer == CMP_N) pt_texte->m_Layer = SILKSCREEN_N_CMP; if( (Module->m_Layer == SILKSCREEN_N_CU) || (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) ) pt_texte->m_Miroir = 0 ; /* Inversion miroir de la Valeur et mise en miroir : */ pt_texte = Module->m_Value; pt_texte->m_Pos.y -= Module->m_Pos.y; pt_texte->m_Pos.y = -pt_texte->m_Pos.y; pt_texte->m_Pos.y += Module->m_Pos.y; pt_texte->m_Pos0.y = pt_texte->m_Pos0.y; pt_texte->m_Miroir = 1 ; NEGATE_AND_NORMALIZE_ANGLE_POS(pt_texte->m_Orient); pt_texte->m_Layer = Module->m_Layer; pt_texte->m_Layer = ChangeSideNumLayer(pt_texte->m_Layer); if( Module->m_Layer == CUIVRE_N) pt_texte->m_Layer = SILKSCREEN_N_CU; if( Module->m_Layer == CMP_N) pt_texte->m_Layer = SILKSCREEN_N_CMP; if( (Module->m_Layer == SILKSCREEN_N_CU) || (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) ) pt_texte->m_Miroir = 0 ; /* Inversion miroir des dessins de l'empreinte : */ PtStruct = Module->m_Drawings; for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext) { switch( PtStruct->m_StructType) { case TYPEEDGEMODULE: pt_edgmod = (EDGE_MODULE *) PtStruct; pt_edgmod->m_Start.y -= Module->m_Pos.y; pt_edgmod->m_Start.y = -pt_edgmod->m_Start.y ; pt_edgmod->m_Start.y += Module->m_Pos.y; pt_edgmod->m_End.y -= Module->m_Pos.y; pt_edgmod->m_End.y = -pt_edgmod->m_End.y ; pt_edgmod->m_End.y += Module->m_Pos.y; /* inversion des coords locales */ pt_edgmod->m_Start0.y = -pt_edgmod->m_Start0.y; pt_edgmod->m_End0.y = -pt_edgmod->m_End0.y; if ( pt_edgmod->m_Shape == S_ARC ) { pt_edgmod->m_Angle = - pt_edgmod->m_Angle; } pt_edgmod->m_Layer = ChangeSideNumLayer(pt_edgmod->m_Layer); break; case TYPETEXTEMODULE: /* Inversion miroir de la position et mise en miroir : */ pt_texte = (TEXTE_MODULE*)PtStruct; pt_texte->m_Pos.y -= Module->m_Pos.y; pt_texte->m_Pos.y = -pt_texte->m_Pos.y; pt_texte->m_Pos.y += Module->m_Pos.y; pt_texte->m_Pos0.y = pt_texte->m_Pos0.y; pt_texte->m_Miroir = 1 ; NEGATE_AND_NORMALIZE_ANGLE_POS(pt_texte->m_Orient); pt_texte->m_Layer = Module->m_Layer; pt_texte->m_Layer = ChangeSideNumLayer(pt_texte->m_Layer); if( Module->m_Layer == CUIVRE_N) pt_texte->m_Layer = SILKSCREEN_N_CU; if(Module->m_Layer == CMP_N) pt_texte->m_Layer = SILKSCREEN_N_CMP; if((Module->m_Layer == SILKSCREEN_N_CU) || (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N)) pt_texte->m_Miroir = 0 ; break; default: DisplayError(this, wxT("Unknown Draw Type")); break; } } /* calcul du rectangle d'encadrement */ Module->Set_Rectangle_Encadrement(); Module->Display_Infos(this); if( !(Module->m_Flags & IS_MOVED) ) /* Inversion simple */ { if ( DC ) { Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR); /* affichage chevelu general si necessaire */ ReCompile_Ratsnest_After_Changes( DC ); } } else { if ( DC ) { DrawModuleOutlines(DrawPanel, DC, Module); Dessine_Segments_Dragges(DrawPanel, DC); } m_Pcb->m_Status_Pcb &= ~CHEVELU_LOCAL_OK; } }