void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
    PCB_SCREEN* screen = GetScreen();

    if( !GetBoard() || !screen )
        return;

    GRSetDrawMode( DC, GR_COPY );

    m_canvas->DrawBackGround( DC );
    DrawWorkSheet( DC, screen, 0, IU_PER_MILS, wxEmptyString );

    // Redraw the footprints
    for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
        module->Draw( m_canvas, DC, GR_OR | GR_ALLOW_HIGHCONTRAST );

#ifdef USE_WX_OVERLAY

    if( IsShown() )
    {
        m_overlay.Reset();
        wxDCOverlay overlaydc( m_overlay, (wxWindowDC*) DC );
        overlaydc.Clear();
    }

#endif

    if( m_canvas->IsMouseCaptured() )
        m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );

    // Redraw the cursor
    m_canvas->DrawCrossHair( DC );
}
Exemplo n.º 2
0
MODULE * WinEDA_PcbFrame::Create_MuWaveBasicShape(wxDC * DC,
			const wxString & name, int pad_count)
/***************************************************************************/
/* Create a footprint with pad_count pads for micro wave applications
This footprint has pad_count pads:
 SMD, rectangular, H size = V size = current track width.
*/
{
MODULE * Module;
int pad_num = 1;
char Line[256];	

	Module = Create_1_Module(DC, name);
	if ( Module == NULL ) return NULL;
	
	Module->m_TimeStamp = GetTimeStamp();
	Module->m_Value->m_Size = wxSize(30,30);
	Module->m_Value->m_Pos0.y = -30;
	Module->m_Value->m_Pos.y += Module->m_Value->m_Pos0.y;
	Module->m_Reference->m_Size = wxSize(30,30);
	Module->m_Reference->m_Pos0.y = 30;
	Module->m_Reference->m_Pos.y += Module->m_Reference->m_Pos0.y;

	/* Creation des pastilles formant le gap */
	while ( pad_count -- )
	{
	D_PAD* pad;
		pad = new D_PAD(Module);
		pad->Pback = Module;
		if ( Module->m_Pads == NULL )
		{
			Module->m_Pads = pad;
		}
		else
		{
			Module->m_Pads->Pback = pad;
			pad->Pnext = Module->m_Pads;
			Module->m_Pads = pad;
		}
		pad->m_Size.x = pad->m_Size.y = g_DesignSettings.m_CurrentTrackWidth;
		pad->m_Pos = Module->m_Pos;
		pad->m_PadShape = RECT;
		pad->m_Attribut = SMD;
		pad->m_Masque_Layer = CMP_LAYER;
		sprintf(Line, "%d", pad_num);
		pad->SetPadName(Line);
		pad_num++;
	}

	if (DC) Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR) ;
	return Module;
}
Exemplo n.º 3
0
static void Exit_Muonde(WinEDA_DrawFrame * frame, wxDC *DC )
/**********************************************************/
{
MODULE * Module = (MODULE*) frame->m_CurrentScreen->m_CurrentItem;

	if( Module )
		{
		if ( Module->m_Flags & IS_NEW)
			{
			Module->Draw(frame->DrawPanel, DC, wxPoint(0,0), GR_XOR) ;
			DeleteStructure( Module);
			}
		else
			{
			Module->Draw(frame->DrawPanel, DC, wxPoint(0,0), GR_XOR) ;
			}
		}

	frame->m_CurrentScreen->ManageCurseur = NULL;
	frame->m_CurrentScreen->ForceCloseManageCurseur = NULL;
	frame->m_CurrentScreen->m_CurrentItem = NULL;
}
// Rotate selected pad 90 degrees.
void PCB_BASE_FRAME::RotatePad( D_PAD* aPad, wxDC* DC )
{
    if( aPad == NULL )
        return;

    MODULE* module = aPad->GetParent();

    module->SetLastEditTime();

    OnModify();

    if( DC )
        module->Draw( m_canvas, DC, GR_XOR );

    wxSize  sz = aPad->GetSize();
    EXCHG( sz.x, sz.y );
    aPad->SetSize( sz );

    sz = aPad->GetDrillSize();
    EXCHG( sz.x, sz.y );
    aPad->SetDrillSize( sz );

    wxPoint pt = aPad->GetOffset();
    EXCHG( pt.x, pt.y );
    aPad->SetOffset( pt );

    aPad->SetOffset( wxPoint( aPad->GetOffset().x, -aPad->GetOffset().y ) );

    sz = aPad->GetDelta();
    EXCHG( sz.x, sz.y );
    sz.x = -sz.x;
    aPad->SetDelta( sz );

    module->CalculateBoundingBox();
    SetMsgPanel( aPad );

    if( DC )
        module->Draw( m_canvas, DC, GR_OR );
}
Exemplo n.º 5
0
void PCB_EDIT_FRAME::Begin_Self( wxDC* DC )
{
    if( s_inductor_pattern.m_Flag )
    {
        m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
        m_canvas->SetMouseCapture( NULL, NULL );

        wxString errorMessage;

        // Prepare parameters for inductor
        // s_inductor_pattern.m_Start is already initialized,
        // when s_inductor_pattern.m_Flag == false
        s_inductor_pattern.m_Width = GetDesignSettings().GetCurrentTrackWidth();
        s_inductor_pattern.m_End = GetCrossHairPosition();

        MODULE* footprint = CreateMicrowaveInductor( this, errorMessage );

        if( footprint )
        {
            SetMsgPanel( footprint );
            footprint->Draw( m_canvas, DC, GR_OR );
        }

        else if( !errorMessage.IsEmpty() )
            DisplayError( this, errorMessage );

        return;
    }

    s_inductor_pattern.m_Start = GetCrossHairPosition();
    s_inductor_pattern.m_End   = s_inductor_pattern.m_Start;

    s_inductor_pattern.m_Flag = true;

    // Update the initial coordinates.
    GetScreen()->m_O_Curseur = GetCrossHairPosition();
    UpdateStatusBar();

    m_canvas->SetMouseCapture( ShowBoundingBoxMicroWaveInductor, Exit_Self );
    m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
}
Exemplo n.º 6
0
void WinEDA_ModuleEditFrame::RedrawActiveWindow(wxDC * DC, bool EraseBg)
/**********************************************************************/

/* Trace le PCB, et les elements complementaires ( axes, grille .. )
 pour l'ecran actif et ses sous ecran
*/

{
MODULE * Module;
PCB_SCREEN * screen = GetScreen();

	if ( ! m_Pcb || ! screen ) return;

	ActiveScreen = screen;
	GRSetDrawMode(DC, GR_COPY);

	if ( EraseBg ) DrawPanel->EraseScreen(DC);

	DrawPanel->DrawBackGround(DC);
	TraceWorkSheet(DC, screen);

	Module = (MODULE*) m_Pcb->m_Modules;
	for ( ; Module != NULL; Module = (MODULE *) Module->Pnext )
		{
		Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR);
		}


	Affiche_Status_Box();

	if( screen->ManageCurseur )
		screen->ManageCurseur(DrawPanel, DC, FALSE);

	/* Reaffichage du curseur */
	screen->Trace_Curseur(DrawPanel, DC);

	screen->ClrRefreshReq();
}
// Redraw the BOARD items but not cursors, axis or grid
void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, GR_DRAWMODE aDrawMode, const wxPoint& offset )
{
    /* The order of drawing is flexible on some systems and not on others.  For
     * OSes which use OR to draw, the order is not important except for the
     * effect of the highlight and its relationship to markers. See comment
     * below.
     * This order independence comes from the fact that a binary OR operation is
     * commutative in nature.
     * However on the OSX, the OR operation is not used, and so this sequence
     * below is chosen to give MODULEs the highest visible priority.
     */

    /* Draw all tracks and zones.  As long as dark colors are used for the
     * tracks,  Then the OR draw mode should show tracks underneath other
     * tracks.  But a white track will cover any other color since it has
     * more bits to OR in.
     */
    for( TRACK* track = m_Track; track; track = track->Next() )
    {
        if( track->IsMoving() )
            continue;

        track->Draw( aPanel, DC, aDrawMode );
    }

    // Draw areas (i.e. zones)
    for( int ii = 0; ii < GetAreaCount(); ii++ )
    {
        ZONE_CONTAINER* zone = GetArea( ii );

        // Areas must be drawn here only if not moved or dragged,
        // because these areas are drawn by ManageCursor() in a specific manner
        if( ( zone->GetEditFlags() & (IN_EDIT | IS_DRAGGED | IS_MOVED) ) == 0 )
        {
            zone->Draw( aPanel, DC, aDrawMode );
            zone->DrawFilledArea( aPanel, DC, aDrawMode );
        }
    }

    // Draw the graphic items
    for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
    {
        if( item->IsMoving() )
            continue;

        switch( item->Type() )
        {
        case PCB_DIMENSION_T:
        case PCB_TEXT_T:
        case PCB_TARGET_T:
        case PCB_LINE_T:
            item->Draw( aPanel, DC, aDrawMode );
            break;

        default:
            break;
        }
    }

    LSET all_cu = LSET::AllCuMask();

    for( MODULE* module = m_Modules; module; module = module->Next() )
    {
        bool    display = true;
        LSET    layerMask = all_cu;

        if( module->IsMoving() )
            continue;

        if( !IsElementVisible( LAYER_MOD_FR ) )
        {
            if( module->GetLayer() == F_Cu )
                display = false;

            layerMask.set( F_Cu, false );
        }

        if( !IsElementVisible( LAYER_MOD_BK ) )
        {
            if( module->GetLayer() == B_Cu )
                display = false;

            layerMask.set( B_Cu, false );
        }

        if( display )
            module->Draw( aPanel, DC, aDrawMode );
        else
            Trace_Pads_Only( aPanel, DC, module, 0, 0, layerMask, aDrawMode );
    }

    // draw the BOARD's markers last, otherwise the high light will erase any marker on a pad
    for( unsigned i = 0; i < m_markers.size(); ++i )
    {
        m_markers[i]->Draw( aPanel, DC, aDrawMode );
    }
}
Exemplo n.º 8
0
MODULE * WinEDA_PcbFrame::Create_MuWaveComponent(wxDC * DC, int shape_type)
/***************************************************************************/
/* Create a module "GAP" or "STUB"
This a "gap" or  "stub" used in micro wave designs
This modue has 2 pads:
 SMD, rectangular, H size = V size = current track width.
 the "gap" is isolation created between this 2 pads 
*/
{
int gap_size, oX, ii;
float fcoeff;
D_PAD* pt_pad;
MODULE * Module;
wxString msg, cmp_name;
int pad_count = 2;
int angle = 0;
bool abort;
	
	/* Entree de la longueur desiree du gap*/
	gap_size = g_DesignSettings.m_CurrentTrackWidth;		// Valeur raisonnable

	switch ( shape_type )
	{
		case 0:
			msg = _("Gap");
			cmp_name = "GAP";
			break;

		case 1:
			msg = _("Stub");
			cmp_name = "STUB";
			pad_count = 2;
			break;

		case 2:
			msg = _("Arc Stub");
			cmp_name = "ASTUB";
			pad_count = 1;
			break;

		default:
			msg = "???";
			break;
	}
	
	DrawPanel->m_IgnoreMouseEvents = TRUE;

wxString value;	
	if( UnitMetric)
	{
		fcoeff = 10000.0/25.4 ;
		value.Printf("%2.4f",gap_size / fcoeff);
		msg += " (mm):";
		abort = Get_Message(msg,value, this);
	}
	else
	{
		fcoeff = 10000.0 ;
		value.Printf("%2.3f",gap_size / fcoeff);
		msg += _(" (inch):");
		abort = Get_Message(msg, value, this);
	}

	double fval;
	if ( ! value.ToDouble(&fval) )
	{
		DisplayError(this, _("Incorrect number, abort"));
		abort = TRUE;
	}
	gap_size = ABS( (int) round( fval * fcoeff ));

	if ( ! abort && (shape_type == 2) )
	{
		fcoeff = 10.0 ;
		value.Printf( "%3.1f",angle / fcoeff);
		msg = _("Angle (0.1deg):");
		abort = Get_Message(msg, value, this);
		if ( ! value.ToDouble(&fval) )
		{
			DisplayError(this, _("Incorrect number, abort"));
			abort = TRUE;
		}
		angle = ABS( (int) round( fval * fcoeff ));
		if ( angle > 1800 ) angle = 1800;
	}

	if (abort)
	{
		DrawPanel->MouseToCursorSchema();
		DrawPanel->m_IgnoreMouseEvents = FALSE;
		return NULL;
	}

	Module = Create_MuWaveBasicShape(NULL, cmp_name, pad_count);	
	pt_pad = Module->m_Pads;

	switch ( shape_type )
	{
		case 0:	//Gap :
			oX = pt_pad->m_Pos0.x = - (gap_size + pt_pad->m_Size.x) / 2;
			pt_pad->m_Pos.x += pt_pad->m_Pos0.x;
		
			pt_pad = (D_PAD *) pt_pad->Pnext;
			pt_pad->m_Pos0.x = oX + gap_size + pt_pad->m_Size.x;
			pt_pad->m_Pos.x += pt_pad->m_Pos0.x;
			break;

		case 1:	//Stub :
			pt_pad->SetPadName("1");
			pt_pad = (D_PAD *) pt_pad->Pnext;
			pt_pad->m_Pos0.y = -(gap_size + pt_pad->m_Size.y) /2;
			pt_pad->m_Size.y = gap_size;
			pt_pad->m_Pos.y += pt_pad->m_Pos0.y;
			break;
		
		case 2:	//Arc Stub :
		{
			EDGE_MODULE * edge; int * ptr, theta;
			ii = angle / 50; 
			edge = new EDGE_MODULE(Module);
			Module->m_Drawings = edge;
			edge->Pback = Module;
			edge->m_Shape = S_POLYGON;
			edge->m_Layer = LAYER_CMP_N;
			edge->m_PolyCount = ii + 3;
			edge->m_PolyList = (int*) MyMalloc( edge->m_PolyCount * 2 * sizeof(int) );
			ptr = edge->m_PolyList;
			edge->m_Start0.y = - pt_pad->m_Size.y / 2;
			
			* ptr = 0; ptr++;
			* ptr = 0; ptr++;
			theta = - angle/2;
			for ( ii = 1; ii < edge->m_PolyCount - 1; ii ++)
			{
				int x, y;
				x = 0; y = - gap_size;
				RotatePoint(&x, &y, theta);
				* ptr = x; ptr++; *ptr = y; ptr++;
				theta += 50;
				if ( theta > angle/2) theta = angle/2;
			}
			*ptr = edge->m_PolyList[0]; ptr++;
			*ptr = edge->m_PolyList[1];
			break;
		}
		
		default:
			break;
	}

	Module->Set_Rectangle_Encadrement();
	Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR) ;
	DrawPanel->MouseToCursorSchema();
	DrawPanel->m_IgnoreMouseEvents = FALSE;
	m_Pcb->m_Status_Pcb = 0 ;
	m_CurrentScreen->SetModify();
	return Module;
}
Exemplo n.º 9
0
MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary,
                                               FP_LIB_TABLE*   aTable,
                                               bool            aUseFootprintViewer,
                                               wxDC*           aDC )
{
    MODULE*     module = NULL;
    wxPoint     curspos = GetCrossHairPosition();
    wxString    moduleName, keys;
    wxString    libName = aLibrary;
    bool        allowWildSeach = true;

    static wxArrayString HistoryList;
    static wxString      lastComponentName;

    // Ask for a component name or key words
    DIALOG_GET_COMPONENT dlg( this, HistoryList, _( "Load Module" ), aUseFootprintViewer );

    dlg.SetComponentName( lastComponentName );

    if( dlg.ShowModal() == wxID_CANCEL )
        return NULL;

    if( dlg.m_GetExtraFunction )
    {
        // SelectFootprintFromLibBrowser() returns the "full" footprint name, i.e.
        // <lib_name>/<footprint name> or FPID format "lib_name:fp_name:rev#"
        moduleName = SelectFootprintFromLibBrowser();
    }
    else
    {
        moduleName = dlg.GetComponentName();
    }

    if( moduleName.IsEmpty() )  // Cancel command
    {
        m_canvas->MoveCursorToCrossHair();
        return NULL;
    }

    if( dlg.IsKeyword() )                          // Selection by keywords
    {
        allowWildSeach = false;
        keys = moduleName;
        moduleName = SelectFootprint( this, libName, wxEmptyString, keys, aTable );

        if( moduleName.IsEmpty() )                 // Cancel command
        {
            m_canvas->MoveCursorToCrossHair();
            return NULL;
        }
    }
    else if( moduleName.Contains( wxT( "?" ) )
           || moduleName.Contains( wxT( "*" ) ) )  // Selection wild card
    {
        allowWildSeach = false;
        moduleName     = SelectFootprint( this, libName, moduleName, wxEmptyString, aTable );

        if( moduleName.IsEmpty() )
        {
            m_canvas->MoveCursorToCrossHair();
            return NULL;                           // Cancel command.
        }
    }

    FPID fpid;

    wxCHECK_MSG( fpid.Parse( moduleName ) < 0, NULL,
                 wxString::Format( wxT( "Could not parse FPID string '%s'." ),
                                   GetChars( moduleName ) ) );

    try
    {
        module = loadFootprint( fpid );
    }
    catch( const IO_ERROR& ioe )
    {
        wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ),
                    fpid.Format().c_str(), GetChars( ioe.errorText ) );
    }

    if( !module && allowWildSeach )                // Search with wild card
    {
        allowWildSeach = false;

        wxString wildname = wxChar( '*' ) + moduleName + wxChar( '*' );
        moduleName = wildname;

        moduleName = SelectFootprint( this, libName, moduleName, wxEmptyString, aTable );

        if( moduleName.IsEmpty() )
        {
            m_canvas->MoveCursorToCrossHair();
            return NULL;    // Cancel command.
        }
        else
        {
            FPID fpid;

            wxCHECK_MSG( fpid.Parse( moduleName ) < 0, NULL,
                         wxString::Format( wxT( "Could not parse FPID string '%s'." ),
                                           GetChars( moduleName ) ) );

            try
            {
                module = loadFootprint( fpid );
            }
            catch( const IO_ERROR& ioe )
            {
                wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ),
                            fpid.Format().c_str(), GetChars( ioe.errorText ) );
            }
        }
    }

    SetCrossHairPosition( curspos );
    m_canvas->MoveCursorToCrossHair();

    if( module )
    {
        GetBoard()->Add( module, ADD_APPEND );
        lastComponentName = moduleName;
        AddHistoryComponentName( HistoryList, moduleName );

        module->SetFlags( IS_NEW );
        module->SetLink( 0 );
        module->SetPosition( curspos );
        module->SetTimeStamp( GetNewTimeStamp() );
        GetBoard()->m_Status_Pcb = 0;

        // Put it on FRONT layer,
        // (Can be stored flipped if the lib is an archive built from a board)
        if( module->IsFlipped() )
            module->Flip( module->GetPosition() );

        // Place it in orientation 0,
        // even if it is not saved with orientation 0 in lib
        // (Can happen if the lib is an archive built from a board)
        Rotate_Module( NULL, module, 0, false );

        RecalculateAllTracksNetcode();

        if( aDC )
            module->Draw( m_canvas, aDC, GR_OR );
    }

    return module;
}
Exemplo n.º 10
0
MODULE * WinEDA_BasePcbFrame::Load_Module_From_Library(const wxString & library,
			wxDC * DC)
/****************************************************************************/
/* Permet de charger un module directement a partir de la librairie */
{
MODULE * module;
wxPoint curspos = m_CurrentScreen->m_Curseur;
wxString ModuleName, keys;
static wxArrayString HistoryList;
bool AllowWildSeach = TRUE;

	/* Ask for a component name or key words */
	ModuleName = GetComponentName(this, HistoryList, _("Module name:"), NULL);
	ModuleName.MakeUpper();
	if( ModuleName.IsEmpty() )	/* Cancel command */
	{
		DrawPanel->MouseToCursorSchema();
		return NULL;
	}


	if( ModuleName[0] == '=' )	// Selection by keywords
	{
		AllowWildSeach = FALSE;
		keys = ModuleName.AfterFirst('=');
		ModuleName = Select_1_Module_From_List(this, library, wxEmptyString, keys);
		if( ModuleName.IsEmpty() )	/* Cancel command */
		{
			DrawPanel->MouseToCursorSchema();
			return NULL;
		}
	}

	else if( (ModuleName.Contains(wxT("?"))) || (ModuleName.Contains(wxT("*"))) ) // Selection wild card
	{
		AllowWildSeach = FALSE;
		ModuleName = Select_1_Module_From_List(this, library, ModuleName, wxEmptyString);
		if( ModuleName.IsEmpty() )
		{
			DrawPanel->MouseToCursorSchema();
			return NULL;	/* annulation de commande */
		}
	}

	module = Get_Librairie_Module(this, library, ModuleName, FALSE);

	if( (module == NULL) && AllowWildSeach )	/* Attemp to search with wildcard */
	{
		AllowWildSeach = FALSE;
		wxString wildname = wxChar('*') + ModuleName + wxChar('*');
		ModuleName = wildname;
		ModuleName = Select_1_Module_From_List(this, library, ModuleName, wxEmptyString);
		if( ModuleName.IsEmpty() )
		{
			DrawPanel->MouseToCursorSchema();
			return NULL;	/* annulation de commande */
		}
		else module = Get_Librairie_Module(this, library, ModuleName, TRUE);
	}

	m_CurrentScreen->m_Curseur = curspos;
	DrawPanel->MouseToCursorSchema();

	if( module )
	{
		AddHistoryComponentName(HistoryList, ModuleName);

		module->m_Flags = IS_NEW;
		module->m_Link = 0;
		module->m_TimeStamp = GetTimeStamp();
		m_Pcb->m_Status_Pcb = 0 ;
		module->SetPosition(curspos);
		build_liste_pads();

		module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR);
	}

	return module;
}
Exemplo n.º 11
0
void WinEDA_PcbFrame::Trace_Pcb(wxDC * DC, int mode)
/****************************************************/
/* Trace l'ensemble des elements du PCB sur l'ecran actif*/
{
MARQUEUR * Marqueur;
MODULE * Module;
EDA_BaseStruct * PtStruct;

	if ( ! m_Pcb ) return;

	Module = (MODULE*) m_Pcb->m_Modules;
	for ( ; Module != NULL; Module = (MODULE *) Module->Pnext )
		{
		bool display = TRUE, MaskLay = ALL_CU_LAYERS;
		if( Module->m_Flags & IS_MOVED ) continue ;

		if( ! DisplayOpt.Show_Modules_Cmp )
			{
			if(Module->m_Layer == CMP_N) display = FALSE;
			MaskLay &= ~CMP_LAYER;
			}
		if( ! DisplayOpt.Show_Modules_Cu )
			{
			if(Module->m_Layer == CUIVRE_N) display = FALSE;
			MaskLay &= ~CUIVRE_LAYER;
			}

		if ( display ) Module->Draw(DrawPanel, DC, wxPoint(0,0), mode);
		else  Trace_Pads_Only(DrawPanel, DC, Module, 0, 0, MaskLay, mode);
		}

	/* Trace des elements particuliers de Drawings Pcb */

	PtStruct = m_Pcb->m_Drawings;
	for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
		{
		if ( PtStruct->m_Flags & IS_MOVED ) continue;

		switch(PtStruct->m_StructType)
			{
			case TYPECOTATION:
				((COTATION*) PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0), mode);
				break;

			case TYPETEXTE:
				((TEXTE_PCB*) PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0), mode );
				break;

			case TYPEMIRE:
				((MIREPCB*) PtStruct)->Draw(DrawPanel, DC, wxPoint(0,0), mode);
				break;

			case TYPEMARQUEUR:	 /* Trace des marqueurs */
				Marqueur = ( MARQUEUR*) PtStruct;
				Marqueur->Draw(DrawPanel, DC, mode);
				break;

			default: break;
			}
		}

	Trace_Pistes(DrawPanel, m_Pcb, DC, mode);
	if ( g_HightLigt_Status ) DrawHightLight(DC, g_HightLigth_NetCode) ;

	EDGE_ZONE * segment = m_Pcb->m_CurrentLimitZone;
	for( ; segment != NULL; segment = (EDGE_ZONE *) segment->Pback)
		{
		if ( segment->m_Flags & IS_MOVED ) continue;
		Trace_DrawSegmentPcb(DrawPanel, DC, segment, mode);
		}

	Trace_PcbEdges(DC, mode);
	DrawGeneralRatsnest(DC);

	m_CurrentScreen->ClrRefreshReq();
}
Exemplo n.º 12
0
MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC )
{
    D_PAD*   pad;
    int      ll;
    wxString msg;

    m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
    m_canvas->SetMouseCapture( NULL, NULL );

    if( s_inductor_pattern.m_Flag == false )
    {
        DisplayError( this, wxT( "Starting point not init.." ) );
        return NULL;
    }

    s_inductor_pattern.m_Flag = false;

    s_inductor_pattern.m_End = GetCrossHairPosition();

    wxPoint pt = s_inductor_pattern.m_End - s_inductor_pattern.m_Start;
    int     min_len = KiROUND( EuclideanNorm( pt ) );
    s_inductor_pattern.m_lenght = min_len;

    // Enter the desired length.
    msg = StringFromValue( g_UserUnit, s_inductor_pattern.m_lenght );
    wxTextEntryDialog dlg( this, wxEmptyString, _( "Length of Trace:" ), msg );

    if( dlg.ShowModal() != wxID_OK )
        return NULL; // canceled by user

    msg = dlg.GetValue();
    s_inductor_pattern.m_lenght = ValueFromString( g_UserUnit, msg );

    // Control values (ii = minimum length)
    if( s_inductor_pattern.m_lenght < min_len )
    {
        DisplayError( this, _( "Requested length < minimum length" ) );
        return NULL;
    }

    // Calculate the elements.
    s_inductor_pattern.m_Width = GetDesignSettings().GetCurrentTrackWidth();

    std::vector <wxPoint> buffer;
    ll = BuildCornersList_S_Shape( buffer, s_inductor_pattern.m_Start,
                                   s_inductor_pattern.m_End, s_inductor_pattern.m_lenght,
                                   s_inductor_pattern.m_Width );

    if( !ll )
    {
        DisplayError( this, _( "Requested length too large" ) );
        return NULL;
    }

    // Generate footprint. the value is also used as footprint name.
    msg.Empty();
    wxTextEntryDialog cmpdlg( this, wxEmptyString, _( "Component Value:" ), msg );
    cmpdlg.SetTextValidator( FILE_NAME_CHAR_VALIDATOR( &msg ) );

    if( ( cmpdlg.ShowModal() != wxID_OK ) || msg.IsEmpty() )
        return NULL;    //  Aborted by user

    MODULE* module = CreateNewModule( msg );

    // here the module is already in the BOARD, CreateNewModule() does that.
    module->SetFPID( FPID( std::string( "mw_inductor" ) ) );
    module->SetAttributes( MOD_VIRTUAL | MOD_CMS );
    module->ClearFlags();
    module->SetPosition( s_inductor_pattern.m_End );

    // Generate segments
    for( unsigned jj = 1; jj < buffer.size(); jj++ )
    {
        EDGE_MODULE* PtSegm;
        PtSegm = new EDGE_MODULE( module );
        PtSegm->SetStart( buffer[jj - 1] );
        PtSegm->SetEnd( buffer[jj] );
        PtSegm->SetWidth( s_inductor_pattern.m_Width );
        PtSegm->SetLayer( module->GetLayer() );
        PtSegm->SetShape( S_SEGMENT );
        PtSegm->SetStart0( PtSegm->GetStart() - module->GetPosition() );
        PtSegm->SetEnd0( PtSegm->GetEnd() - module->GetPosition() );
        module->GraphicalItems().PushBack( PtSegm );
    }

    // Place a pad on each end of coil.
    pad = new D_PAD( module );

    module->Pads().PushFront( pad );

    pad->SetPadName( wxT( "1" ) );
    pad->SetPosition( s_inductor_pattern.m_End );
    pad->SetPos0( pad->GetPosition() - module->GetPosition() );

    pad->SetSize( wxSize( s_inductor_pattern.m_Width, s_inductor_pattern.m_Width ) );

    pad->SetLayerSet( LSET( module->GetLayer() ) );
    pad->SetAttribute( PAD_ATTRIB_SMD );
    pad->SetShape( PAD_SHAPE_CIRCLE );

    D_PAD* newpad = new D_PAD( *pad );

    module->Pads().Insert( newpad, pad->Next() );

    pad = newpad;
    pad->SetPadName( wxT( "2" ) );
    pad->SetPosition( s_inductor_pattern.m_Start );
    pad->SetPos0( pad->GetPosition() - module->GetPosition() );

    // Modify text positions.
    SetMsgPanel( module );

    wxPoint refPos( ( s_inductor_pattern.m_Start.x + s_inductor_pattern.m_End.x ) / 2,
                    ( s_inductor_pattern.m_Start.y + s_inductor_pattern.m_End.y ) / 2 );

    wxPoint valPos = refPos;

    refPos.y -= module->Reference().GetSize().y;
    module->Reference().SetPosition( refPos );
    valPos.y += module->Value().GetSize().y;
    module->Value().SetPosition( valPos );

    module->CalculateBoundingBox();
    module->Draw( m_canvas, DC, GR_OR );

    return module;
}
Exemplo n.º 13
0
MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC )
{
    D_PAD*   pad;
    int      ll;
    wxString msg;

    m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
    m_canvas->SetMouseCapture( NULL, NULL );

    if( Self_On == 0 )
    {
        DisplayError( this, wxT( "Starting point not init.." ) );
        return NULL;
    }

    Self_On = 0;

    Mself.m_End = GetCrossHairPosition();

    wxPoint pt = Mself.m_End - Mself.m_Start;
    int     min_len = KiROUND( EuclideanNorm( pt ) );
    Mself.lng = min_len;

    // Enter the desired length.
    msg = StringFromValue( g_UserUnit, Mself.lng );
    wxTextEntryDialog dlg( this, _( "Length:" ), _( "Length" ), msg );

    if( dlg.ShowModal() != wxID_OK )
        return NULL; // canceled by user

    msg = dlg.GetValue();
    Mself.lng = ValueFromString( g_UserUnit, msg );

    // Control values (ii = minimum length)
    if( Mself.lng < min_len )
    {
        DisplayError( this, _( "Requested length < minimum length" ) );
        return NULL;
    }

    // Calculate the elements.
    Mself.m_Width = GetBoard()->GetCurrentTrackWidth();

    std::vector <wxPoint> buffer;
    ll = BuildCornersList_S_Shape( buffer, Mself.m_Start, Mself.m_End, Mself.lng, Mself.m_Width );

    if( !ll )
    {
        DisplayError( this, _( "Requested length too large" ) );
        return NULL;
    }

    // Generate module.
    MODULE* module;
    module = Create_1_Module( wxEmptyString );

    if( module == NULL )
        return NULL;

    // here the module is already in the BOARD, Create_1_Module() does that.
    module->SetFPID( FPID( std::string( "MuSelf" ) ) );
    module->SetAttributes( MOD_VIRTUAL | MOD_CMS );
    module->ClearFlags();
    module->SetPosition( Mself.m_End );

    // Generate segments
    for( unsigned jj = 1; jj < buffer.size(); jj++ )
    {
        EDGE_MODULE* PtSegm;
        PtSegm = new EDGE_MODULE( module );
        PtSegm->SetStart( buffer[jj - 1] );
        PtSegm->SetEnd( buffer[jj] );
        PtSegm->SetWidth( Mself.m_Width );
        PtSegm->SetLayer( module->GetLayer() );
        PtSegm->SetShape( S_SEGMENT );
        PtSegm->SetStart0( PtSegm->GetStart() - module->GetPosition() );
        PtSegm->SetEnd0(   PtSegm->GetEnd()   - module->GetPosition() );
        module->GraphicalItems().PushBack( PtSegm );
    }

    // Place a pad on each end of coil.
    pad = new D_PAD( module );

    module->Pads().PushFront( pad );

    pad->SetPadName( wxT( "1" ) );
    pad->SetPosition( Mself.m_End );
    pad->SetPos0( pad->GetPosition() - module->GetPosition() );

    pad->SetSize( wxSize( Mself.m_Width, Mself.m_Width ) );

    pad->SetLayerMask( GetLayerMask( module->GetLayer() ) );
    pad->SetAttribute( PAD_SMD );
    pad->SetShape( PAD_CIRCLE );

    D_PAD* newpad = new D_PAD( *pad );

    module->Pads().Insert( newpad, pad->Next() );

    pad = newpad;
    pad->SetPadName( wxT( "2" ) );
    pad->SetPosition( Mself.m_Start );
    pad->SetPos0( pad->GetPosition() - module->GetPosition() );

    // Modify text positions.
    SetMsgPanel( module );

    wxPoint refPos( ( Mself.m_Start.x + Mself.m_End.x ) / 2,
                    ( Mself.m_Start.y + Mself.m_End.y ) / 2 );

    wxPoint valPos = refPos;

    refPos.y -= module->Reference().GetSize().y;
    module->Reference().SetTextPosition( refPos );
    valPos.y += module->Value().GetSize().y;
    module->Value().SetTextPosition( valPos );
    module->Reference().SetPos0( module->Reference().GetTextPosition() - module->GetPosition() );
    module->Value().SetPos0( module->Value().GetTextPosition() - module->GetPosition() );

    module->CalculateBoundingBox();
    module->Draw( m_canvas, DC, GR_OR );

    return module;
}
Exemplo n.º 14
0
void Exit_Module(WinEDA_DrawFrame * frame, wxDC *DC)
/***************************************************/
/* fonction de sortie de l'application */
{
DRAG_SEGM * pt_drag;
TRACK * pt_segm;
MODULE * module;
WinEDA_BasePcbFrame * pcbframe = (WinEDA_BasePcbFrame*)frame; 
	
	module = (MODULE *) frame->m_CurrentScreen->m_CurrentItem;
	pcbframe->m_Pcb->m_Status_Pcb  &= ~CHEVELU_LOCAL_OK;

	if (module)
	{
		// effacement module a l'ecran:
		DrawModuleOutlines(frame->DrawPanel, DC, module);
		/* restitution de l'empreinte si move ou effacement copie*/
		if (module->m_Flags & IS_MOVED )
		{
			/* Move en cours : remise a l'etat d'origine */
			if( g_Drag_Pistes_On)
			{
				/* Effacement des segments dragges */
				pt_drag = g_DragSegmentList;
				for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext)
				{
					pt_segm = pt_drag->m_Segm;
					pt_segm->Draw(frame->DrawPanel, DC, GR_XOR);
				}
			}

			/* Remise en etat d'origine des segments dragges */
			pt_drag = g_DragSegmentList;
			for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext)
			{
				pt_segm = pt_drag->m_Segm; pt_segm->SetState(EDIT,OFF);
				pt_drag->SetInitialValues();
				pt_segm->Draw(frame->DrawPanel, DC, GR_OR);
			}
			EraseDragListe();
			module->m_Flags = 0;
		}

		if (module->m_Flags & IS_NEW )
		{
			DeleteStructure(module);
			module = NULL;
			pcbframe->m_Pcb->m_Status_Pcb = 0 ;
			pcbframe->build_liste_pads() ;
		}
	}

	/* Reaffichage du module a l'ecran */
	if ( module )
	{
		if ( ModuleInitOrient != module->m_Orient )
			pcbframe->Rotate_Module(NULL,module, ModuleInitOrient, FALSE);
		if( ModuleInitLayer != module->m_Layer )
			pcbframe->Change_Side_Module(module, NULL);
		module->Draw(frame->DrawPanel, DC, wxPoint(0,0), GR_OR);
	}
	g_Drag_Pistes_On = FALSE;
	frame->m_CurrentScreen->ManageCurseur = NULL;
	frame->m_CurrentScreen->ForceCloseManageCurseur = NULL;
	frame->m_CurrentScreen->m_CurrentItem = NULL;
}