Commit 6f2c09c6 authored by CHARRAS's avatar CHARRAS

code cleaning

parent e3a3d16a
......@@ -3,6 +3,12 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.
2007-Dec-14 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+pcbnew:
code cleaning:
DRAWSEGMENT class functions moved in the new files class_drawsegment.cpp et .h
2007-Dec-12 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
......
......@@ -37,6 +37,7 @@ SET(CVPCB_EXTRA_SRCS
../pcbnew/basepcbframe.cpp
../pcbnew/class_board.cpp
../pcbnew/class_cotation.cpp
../pcbnew/class_drawsegment.cpp
../pcbnew/class_edge_mod.cpp
../pcbnew/class_equipot.cpp
../pcbnew/class_mire.cpp
......
......@@ -40,6 +40,7 @@ OBJECTS = $(TARGET).o \
zoom.o \
tracemod.o \
classpcb.o \
class_drawsegment.o \
class_board.o \
class_module.o \
class_pad.o \
......@@ -86,6 +87,9 @@ class_pcb_text.o: ../pcbnew/class_pcb_text.cpp ../pcbnew/class_pcb_text.h $(COMM
class_board.o: ../pcbnew/class_board.cpp $(DEPEND)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
class_drawsegment.o: ../pcbnew/class_drawsegment.cpp ../pcbnew/class_drawsegment.h $(DEPEND)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
class_track.o: ../pcbnew/class_track.cpp $(DEPEND)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
......
......@@ -42,6 +42,7 @@ SET(GERBVIEW_SRCS
SET(GERBVIEW_EXTRA_SRCS
../pcbnew/basepcbframe.cpp
../pcbnew/class_board.cpp
../pcbnew/class_drawsegment.cpp
../pcbnew/class_drc_item.cpp
../pcbnew/class_marker.cpp
../pcbnew/class_pcb_text.cpp
......
......@@ -22,6 +22,7 @@ OBJECTS= \
gerberframe.o\
onrightclick.o\
class_board.o\
class_drawsegment.o\
class_track.o \
class_drc_item.o \
drawframe.o\
......@@ -77,6 +78,9 @@ class_marker.o: ../pcbnew/class_marker.cpp ../pcbnew/class_marker.h $(COMMON)
class_zone.o: ../pcbnew/class_zone.cpp ../pcbnew/class_zone.h $(COMMON)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
class_drawsegment.o: ../pcbnew/class_drawsegment.cpp ../pcbnew/class_drawsegment.h $(DEPEND)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
class_drc_item.o: ../pcbnew/class_drc_item.cpp $(COMMON)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
......
......@@ -250,89 +250,7 @@ public:
/* Description des elements du PCB */
/***********************************/
class DRAWSEGMENT : public BOARD_ITEM
{
public:
int m_Width; // 0 = line. if > 0 = tracks, bus ...
wxPoint m_Start; // Line start point
wxPoint m_End; // Line end point
int m_Shape; // Shape: line, Circle, Arc
int m_Type; // Used in complex associations ( Dimensions.. )
int m_Angle; // Used only for Arcs: Arc angle in 1/10 deg
public:
DRAWSEGMENT( BOARD_ITEM* StructFather, KICAD_T idtype = TYPEDRAWSEGMENT );
~DRAWSEGMENT();
/**
* Function GetPosition
* returns the position of this object.
* Required by pure virtual BOARD_ITEM::GetPosition()
* @return const wxPoint& - The position of this object.
*/
wxPoint& GetPosition()
{
return m_Start;
}
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
bool ReadDrawSegmentDescr( FILE* File, int* LineNum );
/* remove this from the linked list */
void UnLink();
void Copy( DRAWSEGMENT* source );
/**
* Function Display_Infos
* has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel.
* Is virtual from EDA_BaseStruct.
* @param frame A WinEDA_BasePcbFrame in which to print status information.
*/
void Display_Infos( WinEDA_DrawFrame* frame );
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param ref_pos A wxPoint to test
* @return bool - true if a hit, else false
*/
bool HitTest( const wxPoint& ref_pos );
/**
* Function HitTest (overlayed)
* tests if the given EDA_Rect intersect this object.
* For now, an ending point must be inside this rect.
* @param refPos the given EDA_Rect to test
* @return bool - true if a hit, else false
*/
bool HitTest( EDA_Rect& refArea );
/**
* Function GetClass
* returns the class name.
* @return wxString
*/
wxString GetClass() const
{
return wxT("DRAWSEGMENT");
}
};
#include "class_drawsegment.h"
#include "class_pcb_text.h"
#include "class_cotation.h"
#include "class_mire.h"
......
......@@ -23,6 +23,7 @@ SET(PCBNEW_SRCS
class_board.cpp
class_board_item.cpp
class_cotation.cpp
class_drawsegment.cpp
class_drc_item.cpp
class_edge_mod.cpp
class_equipot.cpp
......
/***************************************************/
/* class and functions to handle a graphic segment */
/****************************************************/
#include "fctsys.h"
#include "wxstruct.h"
#include "gr_basic.h"
#include "common.h"
#include "pcbnew.h"
#ifdef CVPCB
#include "cvpcb.h"
#endif
#include "trigo.h"
/* DRAWSEGMENT: constructor */
DRAWSEGMENT::DRAWSEGMENT( BOARD_ITEM* StructFather, KICAD_T idtype ) :
BOARD_ITEM( StructFather, idtype )
{
m_Width = m_Flags = m_Shape = m_Type = m_Angle = 0;
}
/* destructor */
DRAWSEGMENT:: ~DRAWSEGMENT()
{
}
void DRAWSEGMENT::UnLink()
/**
* Function UnLink
* remove item from linked list.
*/
{
/* ereas back link */
if( Pback )
{
if( Pback->Type() != TYPEPCB )
{
Pback->Pnext = Pnext;
}
else /* Le chainage arriere pointe sur la structure "Pere" */
{
( (BOARD*) Pback )->m_Drawings = (BOARD_ITEM*) Pnext;
}
}
/* erase forward link */
if( Pnext )
Pnext->Pback = Pback;
Pnext = Pback = NULL;
}
/*******************************************/
void DRAWSEGMENT::Copy( DRAWSEGMENT* source )
/*******************************************/
{
m_Type = source->m_Type;
m_Layer = source->m_Layer;
m_Width = source->m_Width;
m_Start = source->m_Start;
m_End = source->m_End;
m_Shape = source->m_Shape;
m_Angle = source->m_Angle;
m_TimeStamp = source->m_TimeStamp;
}
bool DRAWSEGMENT::Save( FILE* aFile ) const
{
if( GetState( DELETED ) )
return true;
bool rc = false;
if( fprintf( aFile, "$DRAWSEGMENT\n" ) != sizeof("$DRAWSEGMENT\n") - 1 )
goto out;
fprintf( aFile, "Po %d %d %d %d %d %d\n",
m_Shape,
m_Start.x, m_Start.y,
m_End.x, m_End.y, m_Width );
fprintf( aFile, "De %d %d %d %lX %X\n",
m_Layer, m_Type, m_Angle,
m_TimeStamp, ReturnStatus() );
if( fprintf( aFile, "$EndDRAWSEGMENT\n" ) != sizeof("$EndDRAWSEGMENT\n") - 1 )
goto out;
rc = true;
out:
return rc;
}
/******************************************************************/
bool DRAWSEGMENT::ReadDrawSegmentDescr( FILE* File, int* LineNum )
/******************************************************************/
/* Read a DRAWSEGMENT from a file
*/
{
char Line[2048];
while( GetLine( File, Line, LineNum ) != NULL )
{
if( strnicmp( Line, "$End", 4 ) == 0 )
return TRUE; /* End of description */
if( Line[0] == 'P' )
{
sscanf( Line + 2, " %d %d %d %d %d %d",
&m_Shape, &m_Start.x, &m_Start.y,
&m_End.x, &m_End.y, &m_Width );
if( m_Width < 0 )
m_Width = 0;
}
if( Line[0] == 'D' )
{
int status;
sscanf( Line + 2, " %d %d %d %lX %X",
&m_Layer, &m_Type, &m_Angle,
&m_TimeStamp, &status );
if( m_Layer < FIRST_NO_COPPER_LAYER )
m_Layer = FIRST_NO_COPPER_LAYER;
if( m_Layer > LAST_NO_COPPER_LAYER )
m_Layer = LAST_NO_COPPER_LAYER;
SetState( status, ON );
}
}
return FALSE;
}
// see pcbstruct.h
void DRAWSEGMENT::Display_Infos( WinEDA_DrawFrame* frame )
{
int itype;
wxString msg;
frame->MsgPanel->EraseMsgBox();
itype = m_Type & 0x0F;
msg = wxT( "DRAWING" );
Affiche_1_Parametre( frame, 1, _( "Type" ), msg, DARKCYAN );
Affiche_1_Parametre( frame, 16, _( "Shape" ), wxEmptyString, RED );
if( m_Shape == S_CIRCLE )
Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Circle" ), RED );
else if( m_Shape == S_ARC )
{
Affiche_1_Parametre( frame, -1, wxEmptyString, _( " Arc " ), RED );
msg.Printf( wxT( "%d" ), m_Angle );
Affiche_1_Parametre( frame, 32, wxT( " l.arc " ), msg, RED );
}
else
Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Segment" ), RED );
Affiche_1_Parametre( frame, 48, _( "Layer" ),
ReturnPcbLayerName( m_Layer ), BROWN );
valeur_param( (unsigned) m_Width, msg );
Affiche_1_Parametre( frame, 60, _( "Width" ), msg, DARKCYAN );
}
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param ref_pos A wxPoint to test
* @return bool - true if a hit, else false
*/
bool DRAWSEGMENT::HitTest( const wxPoint& ref_pos )
{
int ux0 = m_Start.x;
int uy0 = m_Start.y;
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
int dx = m_End.x - ux0;
int dy = m_End.y - uy0;
int spot_cX = ref_pos.x - ux0;
int spot_cY = ref_pos.y - uy0;
if( m_Shape==S_CIRCLE || m_Shape==S_ARC )
{
int rayon, dist, stAngle, endAngle, mouseAngle;
rayon = (int) hypot( (double) (dx), (double) (dy) );
dist = (int) hypot( (double) (spot_cX), (double) (spot_cY) );
if( abs( rayon - dist ) <= (m_Width / 2) )
{
if( m_Shape == S_CIRCLE )
return true;
/* pour un arc, controle complementaire */
mouseAngle = (int) ArcTangente( spot_cY, spot_cX );
stAngle = (int) ArcTangente( dy, dx );
endAngle = stAngle + m_Angle;
if( endAngle > 3600 )
{
stAngle -= 3600;
endAngle -= 3600;
}
if( mouseAngle >= stAngle && mouseAngle <= endAngle )
return true;
}
}
else
{
if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) )
return true;
}
return false;
}
/**
* Function HitTest (overlayed)
* tests if the given EDA_Rect intersect this object.
* For now, an ending point must be inside this rect.
* @param refArea : the given EDA_Rect
* @return bool - true if a hit, else false
*/
bool DRAWSEGMENT::HitTest( EDA_Rect& refArea )
{
if( refArea.Inside( m_Start ) )
return true;
if( refArea.Inside( m_End ) )
return true;
return false;
}
/*************************************/
/* class to handle a graphic segment */
/**************************************/
#ifndef CLASS_DRAWSEGMENT_H
#define CLASS_DRAWSEGMENT_H
class DRAWSEGMENT : public BOARD_ITEM
{
public:
int m_Width; // 0 = line. if > 0 = tracks, bus ...
wxPoint m_Start; // Line start point
wxPoint m_End; // Line end point
int m_Shape; // Shape: line, Circle, Arc
int m_Type; // Used in complex associations ( Dimensions.. )
int m_Angle; // Used only for Arcs: Arc angle in 1/10 deg
public:
DRAWSEGMENT( BOARD_ITEM* StructFather, KICAD_T idtype = TYPEDRAWSEGMENT );
~DRAWSEGMENT();
/**
* Function GetPosition
* returns the position of this object.
* Required by pure virtual BOARD_ITEM::GetPosition()
* @return const wxPoint& - The position of this object.
*/
wxPoint& GetPosition()
{
return m_Start;
}
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
bool ReadDrawSegmentDescr( FILE* File, int* LineNum );
/* remove this from the linked list */
void UnLink();
void Copy( DRAWSEGMENT* source );
/**
* Function Display_Infos
* has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel.
* Is virtual from EDA_BaseStruct.
* @param frame A WinEDA_BasePcbFrame in which to print status information.
*/
void Display_Infos( WinEDA_DrawFrame* frame );
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param ref_pos A wxPoint to test
* @return bool - true if a hit, else false
*/
bool HitTest( const wxPoint& ref_pos );
/**
* Function HitTest (overlayed)
* tests if the given EDA_Rect intersect this object.
* For now, an ending point must be inside this rect.
* @param refPos the given EDA_Rect to test
* @return bool - true if a hit, else false
*/
bool HitTest( EDA_Rect& refArea );
/**
* Function GetClass
* returns the class name.
* @return wxString
*/
wxString GetClass() const
{
return wxT( "DRAWSEGMENT" );
}
};
#endif // #ifndef CLASS_DRAWSEGMENT_H
This diff is collapsed.
This diff is collapsed.
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_gendrill.h
// Purpose:
// Author: jean-pierre Charras
// Modified by:
// Created: 13/01/2008 17:26:27
// RCS-ID:
// Copyright: License GNU
// Licence:
/////////////////////////////////////////////////////////////////////////////
// Generated by DialogBlocks (unregistered), 13/01/2008 17:26:27
#ifndef _DIALOG_GENDRILL_H_
#define _DIALOG_GENDRILL_H_
/*!
* Includes
*/
////@begin includes
#include "wx/valgen.h"
////@end includes
/*!
* Forward declarations
*/
////@begin forward declarations
class wxBoxSizer;
////@end forward declarations
/*!
* Control identifiers
*/
////@begin control identifiers
#define ID_WINEDA_DRILLFRAME 10000
#define ID_SEL_DRILL_UNITS 10002
#define ID_SEL_ZEROS_FMT 10001
#define ID_SEL_PRECISION 10003
#define ID_SEL_DRILL_SHEET 10004
#define ID_SEL_DRILL_REPORT 10010
#define ID_TEXTCTRL2 10007
#define ID_TEXTCTRL 10006
#define ID_CHECKBOX2 10011
#define ID_CHECKBOX3 10012
#define SYMBOL_WINEDA_DRILLFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL
#define SYMBOL_WINEDA_DRILLFRAME_TITLE _("WinEDA_DrillFrame")
#define SYMBOL_WINEDA_DRILLFRAME_IDNAME ID_WINEDA_DRILLFRAME
#define SYMBOL_WINEDA_DRILLFRAME_SIZE wxSize(400, 300)
#define SYMBOL_WINEDA_DRILLFRAME_POSITION wxDefaultPosition
////@end control identifiers
/*!
* WinEDA_DrillFrame class declaration
*/
class WinEDA_DrillFrame: public wxDialog
{
DECLARE_DYNAMIC_CLASS( WinEDA_DrillFrame )
DECLARE_EVENT_TABLE()
public:
/// Constructors
WinEDA_DrillFrame();
WinEDA_DrillFrame( WinEDA_PcbFrame* parent,
wxWindowID id = SYMBOL_WINEDA_DRILLFRAME_IDNAME,
const wxString& caption = SYMBOL_WINEDA_DRILLFRAME_TITLE,
const wxPoint& pos = SYMBOL_WINEDA_DRILLFRAME_POSITION,
const wxSize& size = SYMBOL_WINEDA_DRILLFRAME_SIZE,
long style = SYMBOL_WINEDA_DRILLFRAME_STYLE );
/// Creation
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_DRILLFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_DRILLFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_DRILLFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_DRILLFRAME_SIZE, long style = SYMBOL_WINEDA_DRILLFRAME_STYLE );
/// Destructor
~WinEDA_DrillFrame();
/// Initialises member variables
void Init();
/// Creates the controls and sizers
void CreateControls();
////@begin WinEDA_DrillFrame event handler declarations
/// wxEVT_CLOSE_WINDOW event handler for ID_WINEDA_DRILLFRAME
void OnCloseWindow( wxCloseEvent& event );
/// wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_SEL_DRILL_UNITS
void OnSelDrillUnitsSelected( wxCommandEvent& event );
/// wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_SEL_ZEROS_FMT
void OnSelZerosFmtSelected( wxCommandEvent& event );
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
void OnOkClick( wxCommandEvent& event );
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE
void OnCloseClick( wxCommandEvent& event );
////@end WinEDA_DrillFrame event handler declarations
////@begin WinEDA_DrillFrame member function declarations
/// Retrieves bitmap resources
wxBitmap GetBitmapResource( const wxString& name );
/// Retrieves icon resources
wxIcon GetIconResource( const wxString& name );
////@end WinEDA_DrillFrame member function declarations
/// Should we show tooltips?
static bool ShowToolTips();
////@begin WinEDA_DrillFrame member variables
wxBoxSizer* m_LeftBoxSizer;
wxRadioBox* m_Choice_Unit;
wxRadioBox* m_Choice_Zeros_Format;
wxRadioBox* m_Choice_Precision;
wxRadioBox* m_Choice_Drill_Offset;
wxRadioBox* m_Choice_Drill_Map;
wxRadioBox* m_Choice_Drill_Report;
wxTextCtrl* m_PenSpeed;
wxTextCtrl* m_PenNum;
wxCheckBox* m_Check_Mirror;
wxCheckBox* m_Check_Minimal;
wxStaticBox* m_DefaultViasDrillSizer;
wxStaticText* m_ViaDrillValue;
wxStaticBox* m_MicroViasDrillSizer;
wxStaticText* m_MicroViaDrillValue;
wxStaticText* m_PadsCountInfoMsg;
wxStaticText* m_ThroughViasInfoMsg;
wxStaticText* m_MicroViasInfoMsg;
wxStaticText* m_BuriedViasInfoMsg;
////@end WinEDA_DrillFrame member variables
private:
WinEDA_PcbFrame* m_Parent;
int m_PadsHoleCount;
int m_ThroughViasCount;
int m_MicroViasCount;
int m_BlindOrBuriedViasCount;
private:
void InitDisplayParams(void);
void SetParams(void);
void GenDrillFiles( wxCommandEvent& event );
void GenDrillMap( int format );
void UpdatePrecisionOptions( wxCommandEvent& event );
void UpdateConfig();
int Plot_Drill_PcbMap( FORET* buffer, int format );
void GenDrillReport();
int Gen_Liste_Forets( FORET* buffer, bool print_header );
int Create_Drill_File_EXCELLON( FORET* buffer );
void Init_Drill();
};
#endif
// _DIALOG_GENDRILL_H_
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -32,6 +32,7 @@ OBJECTS= $(TARGET).o classpcb.o\
setpage.o \
tool_pcb.o \
pcbframe.o \
class_drawsegment.o \
class_track.o \
class_mire.o\
class_cotation.o\
......@@ -265,7 +266,7 @@ readgerb.o: readgerb.cpp pcbplot.h $(COMMON)
plot_rtn.o: plot_rtn.cpp pcbplot.h $(COMMON)
gendrill.o: gendrill.cpp pcbplot.h $(COMMON)
gendrill.o: gendrill.cpp dialog_gendrill.cpp dialog_gendrill.h pcbplot.h $(COMMON)
librairi.o: librairi.cpp $(COMMON)
......
......@@ -89,7 +89,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
if( m_ID_current_state == 0 )
{
DisplayError( this,
wxT( "WinEDA_PcbFrame::OnLeftClick() err: m_Flags != 0" ) );
wxT( "WinEDA_PcbFrame::OnLeftClick() err: DrawType %d m_Flags != 0" ), DrawStruct->Type() );
exit = true;
}
break;
......
......@@ -329,6 +329,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
wxT( "WinEDA_PcbFrame::OnRightClick() Error: illegal DrawType %d" ),
item->Type() );
DisplayError( this, msg );
SetCurItem(NULL);
break;
default:
......@@ -336,6 +337,9 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
wxT( "WinEDA_PcbFrame::OnRightClick() Error: unknown DrawType %d" ),
item->Type() );
DisplayError( this, msg );
// Attempt to clear error (but should no occurs )
if ( item->Type() >= MAX_STRUCT_TYPE_ID )
SetCurItem(NULL);
break;
}
......
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