Commit f1b36209 authored by dickelbeck's avatar dickelbeck

DRAWSEGMENT::Draw()

parent aa93f54d
...@@ -221,103 +221,10 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo ...@@ -221,103 +221,10 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo
void Trace_DrawSegmentPcb( WinEDA_DrawPanel* panel, wxDC* DC, void Trace_DrawSegmentPcb( WinEDA_DrawPanel* panel, wxDC* DC,
DRAWSEGMENT* PtDrawSegment, int draw_mode ) DRAWSEGMENT* PtDrawSegment, int draw_mode )
/**************************************************************************/ /**************************************************************************/
/* Affichage d'un segment type drawing PCB:
* Entree : ox, oy = offset de trace
* draw_mode = mode de trace ( GR_OR, GR_XOR, GrAND)
* Les contours sont de differents type:
* segment
* cercle
* arc
*/
{ {
int ux0, uy0, dx, dy; // @todo Replace all calls to Trace_DrawSegmentPcb() with this call:
int l_piste;
int color, mode;
int zoom = panel->GetZoom();
int rayon;
color = g_DesignSettings.m_LayerColor[PtDrawSegment->GetLayer()];
if( color & ITEM_NOT_SHOW )
return;
GRSetDrawMode( DC, draw_mode );
l_piste = PtDrawSegment->m_Width >> 1; /* l_piste = demi largeur piste */
/* coord de depart */
ux0 = PtDrawSegment->m_Start.x;
uy0 = PtDrawSegment->m_Start.y;
/* coord d'arrivee */
dx = PtDrawSegment->m_End.x;
dy = PtDrawSegment->m_End.y;
mode = DisplayOpt.DisplayPcbTrackFill ? FILLED : SKETCH;
if( PtDrawSegment->m_Flags & FORCE_SKETCH )
mode = SKETCH;
if( l_piste < (L_MIN_DESSIN * zoom) )
mode = FILAIRE;
switch( PtDrawSegment->m_Shape )
{
case S_CIRCLE:
rayon = (int) hypot( (double) (dx - ux0), (double) (dy - uy0) );
if( mode == FILAIRE )
{
GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon, 0, color );
}
else if( mode == SKETCH )
{
GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon - l_piste, 0, color );
GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon + l_piste, 0, color );
}
else
{
GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon, PtDrawSegment->m_Width, color );
}
break;
case S_ARC:
{
int StAngle, EndAngle;
rayon = (int) hypot( (double) (dx - ux0), (double) (dy - uy0) );
StAngle = (int) ArcTangente( dy - uy0, dx - ux0 );
EndAngle = StAngle + PtDrawSegment->m_Angle;
if( mode == FILAIRE )
GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, rayon, 0, color );
else if( mode == SKETCH )
{
GRArc( &panel->m_ClipBox, DC, ux0, uy0, 0, StAngle, EndAngle,
rayon - l_piste, color );
GRArc( &panel->m_ClipBox, DC, ux0, uy0, 0, StAngle, EndAngle,
rayon + l_piste, color );
}
else
{
GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle,
rayon, PtDrawSegment->m_Width, color );
}
}
break;
PtDrawSegment->Draw( panel, DC, draw_mode );
default:
if( mode == FILAIRE )
GRLine( &panel->m_ClipBox, DC, ux0, uy0, dx, dy, 0, color );
else if( mode == SKETCH )
{
GRCSegm( &panel->m_ClipBox, DC, ux0, uy0, dx, dy,
PtDrawSegment->m_Width, color );
}
else
{
GRFillCSegm( &panel->m_ClipBox, DC, ux0, uy0, dx, dy,
PtDrawSegment->m_Width, color );
}
break;
}
} }
......
...@@ -612,9 +612,7 @@ public: ...@@ -612,9 +612,7 @@ public:
* BOARD_ITEMs which have their own color information. * BOARD_ITEMs which have their own color information.
*/ */
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
int aDrawMode, const wxPoint& offset = ZeroOffset ) int aDrawMode, const wxPoint& offset = ZeroOffset ) = 0;
{
}
/** /**
......
...@@ -503,12 +503,11 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -503,12 +503,11 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
switch( PtStruct->Type() ) switch( PtStruct->Type() )
{ {
case TYPEDRAWSEGMENT: case TYPEDRAWSEGMENT:
#undef STRUCT if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 )
#define STRUCT ( (DRAWSEGMENT*) PtStruct )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) )
break; break;
/* l'element est ici bon a etre efface */ /* l'element est ici bon a etre efface */
Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) PtStruct, GR_XOR ); Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) PtStruct, GR_XOR );
PtStruct->DeleteStructure(); PtStruct->DeleteStructure();
...@@ -526,7 +525,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -526,7 +525,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
break; break;
case TYPEMIRE: case TYPEMIRE:
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) )
break; break;
...@@ -535,7 +534,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -535,7 +534,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
break; break;
case TYPECOTATION: case TYPECOTATION:
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) )
break; break;
......
...@@ -252,6 +252,13 @@ public: ...@@ -252,6 +252,13 @@ public:
*/ */
void Display_Infos( WinEDA_DrawFrame* frame ); void Display_Infos( WinEDA_DrawFrame* frame );
void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
int aDrawMode, const wxPoint& offset = ZeroOffset )
{
// void WinEDA_PcbFrame::Trace_Pcb( wxDC* DC, int mode )
// goes here.
}
/** /**
* Function Visit * Function Visit
......
...@@ -144,6 +144,106 @@ bool DRAWSEGMENT::ReadDrawSegmentDescr( FILE* File, int* LineNum ) ...@@ -144,6 +144,106 @@ bool DRAWSEGMENT::ReadDrawSegmentDescr( FILE* File, int* LineNum )
} }
void DRAWSEGMENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
int draw_mode, const wxPoint& notUsed )
{
int ux0, uy0, dx, dy;
int l_piste;
int color, mode;
int zoom;
int rayon;
color = g_DesignSettings.m_LayerColor[GetLayer()];
if( color & ITEM_NOT_SHOW )
return;
if( panel )
zoom = panel->GetZoom();
else
zoom = ActiveScreen->GetZoom();
GRSetDrawMode( DC, draw_mode );
l_piste = m_Width >> 1; /* l_piste = demi largeur piste */
/* coord de depart */
ux0 = m_Start.x;
uy0 = m_Start.y;
/* coord d'arrivee */
dx = m_End.x;
dy = m_End.y;
mode = DisplayOpt.DisplayDrawItems;
if( m_Flags & FORCE_SKETCH )
mode = SKETCH;
if( l_piste < (L_MIN_DESSIN * zoom) )
mode = FILAIRE;
switch( m_Shape )
{
case S_CIRCLE:
rayon = (int) hypot( (double) (dx - ux0), (double) (dy - uy0) );
if( mode == FILAIRE )
{
GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon, color );
}
else if( mode == SKETCH )
{
GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon - l_piste, color );
GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon + l_piste, color );
}
else
{
GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon, m_Width, color );
}
break;
case S_ARC:
{
int StAngle, EndAngle;
rayon = (int) hypot( (double) (dx - ux0), (double) (dy - uy0) );
StAngle = (int) ArcTangente( dy - uy0, dx - ux0 );
EndAngle = StAngle + m_Angle;
if( StAngle > EndAngle )
EXCHG( StAngle, EndAngle );
if( mode == FILAIRE )
GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, rayon, color );
else if( mode == SKETCH )
{
GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle,
rayon - l_piste, color );
GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle,
rayon + l_piste, color );
}
else
{
GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle,
rayon, m_Width, color );
}
}
break;
default:
if( mode == FILAIRE )
GRLine( &panel->m_ClipBox, DC, ux0, uy0, dx, dy, 0, color );
else if( mode == SKETCH )
{
GRCSegm( &panel->m_ClipBox, DC, ux0, uy0, dx, dy,
m_Width, color );
}
else
{
GRFillCSegm( &panel->m_ClipBox, DC, ux0, uy0, dx, dy,
m_Width, color );
}
break;
}
}
// see pcbstruct.h // see pcbstruct.h
void DRAWSEGMENT::Display_Infos( WinEDA_DrawFrame* frame ) void DRAWSEGMENT::Display_Infos( WinEDA_DrawFrame* frame )
{ {
......
...@@ -49,6 +49,9 @@ public: ...@@ -49,6 +49,9 @@ public:
void Copy( DRAWSEGMENT* source ); void Copy( DRAWSEGMENT* source );
void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
int aDrawMode, const wxPoint& offset = ZeroOffset );
/** /**
* Function Display_Infos * Function Display_Infos
* has knowledge about the frame and how and where to put status information * has knowledge about the frame and how and where to put status information
...@@ -86,11 +89,11 @@ public: ...@@ -86,11 +89,11 @@ public:
return wxT( "DRAWSEGMENT" ); return wxT( "DRAWSEGMENT" );
} }
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
#endif #endif
}; };
......
...@@ -33,13 +33,13 @@ public: ...@@ -33,13 +33,13 @@ public:
/** /**
* Function GetPosition * Function GetPosition
* returns the position of this object. * returns the position of this object.
* @return wxPoint& - The position of this object, non-const so it * @return wxPoint& - The position of this object, non-const so it
* can be changed * can be changed
* A dummy to satisfy pure virtual BOARD::GetPosition() * A dummy to satisfy pure virtual BOARD::GetPosition()
*/ */
wxPoint& GetPosition(); wxPoint& GetPosition();
/* Effacement memoire de la structure */ /* Effacement memoire de la structure */
void UnLink(); void UnLink();
...@@ -51,18 +51,25 @@ public: ...@@ -51,18 +51,25 @@ public:
* writes the data structures for this object out to a FILE in "*.brd" format. * writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
int aDrawMode, const wxPoint& offset = ZeroOffset )
{
// @todo we actually could show a NET, simply show all the tracks and pads
}
/** /**
* Function GetNet * Function GetNet
* @return int - the netcode * @return int - the netcode
*/ */
int GetNet() const { return m_NetCode; } int GetNet() const { return m_NetCode; }
void SetNet( int aNetCode ) { m_NetCode = aNetCode; } void SetNet( int aNetCode ) { m_NetCode = aNetCode; }
/** /**
* Function GetClass * Function GetClass
* returns the class name. * returns the class name.
...@@ -73,17 +80,17 @@ public: ...@@ -73,17 +80,17 @@ public:
return wxT("NET"); return wxT("NET");
} }
#if defined(DEBUG) #if defined(DEBUG)
/** /**
* Function Show * Function Show
* is used to output the object tree, currently for debugging only. * is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level * @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree. * of nesting of this object within the overall tree.
* @param os The ostream& to output to. * @param os The ostream& to output to.
*/ */
virtual void Show( int nestLevel, std::ostream& os ); virtual void Show( int nestLevel, std::ostream& os );
#endif #endif
}; };
...@@ -101,6 +101,12 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -101,6 +101,12 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
#define DRAW_CUR_LAYER_LAST 1 #define DRAW_CUR_LAYER_LAST 1
/* should make the function below this one:
void BOARD::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
int aDrawMode, const wxPoint& offset = ZeroOffset );
*/
/****************************************************/ /****************************************************/
void WinEDA_PcbFrame::Trace_Pcb( wxDC* DC, int mode ) void WinEDA_PcbFrame::Trace_Pcb( wxDC* DC, int mode )
/****************************************************/ /****************************************************/
...@@ -149,13 +155,10 @@ void WinEDA_PcbFrame::Trace_Pcb( wxDC* DC, int mode ) ...@@ -149,13 +155,10 @@ void WinEDA_PcbFrame::Trace_Pcb( wxDC* DC, int mode )
case TYPECOTATION: case TYPECOTATION:
case TYPETEXTE: case TYPETEXTE:
case TYPEMIRE: case TYPEMIRE:
case TYPEDRAWSEGMENT:
item->Draw( DrawPanel, DC, mode ); item->Draw( DrawPanel, DC, mode );
break; break;
case TYPEDRAWSEGMENT:
Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) item, mode );
break;
default: default:
break; break;
} }
......
...@@ -62,104 +62,9 @@ void Trace_Une_Piste( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* Track, ...@@ -62,104 +62,9 @@ void Trace_Une_Piste( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* Track,
void Trace_DrawSegmentPcb( WinEDA_DrawPanel* panel, wxDC* DC, void Trace_DrawSegmentPcb( WinEDA_DrawPanel* panel, wxDC* DC,
DRAWSEGMENT* PtDrawSegment, int draw_mode ) DRAWSEGMENT* PtDrawSegment, int draw_mode )
/*************************************************************/ /*************************************************************/
/* Affichage d'un segment type drawing PCB:
* draw_mode = mode de trace ( GR_OR, GR_XOR, GrAND)
* Les contours sont de differents type:
* segment
* cercle
* arc
*/
{ {
int ux0, uy0, dx, dy; // @todo Replace all calls to Trace_DrawSegmentPcb() with this call:
int l_piste;
int color, mode;
int zoom;
int rayon;
color = g_DesignSettings.m_LayerColor[PtDrawSegment->GetLayer()];
if( color & ITEM_NOT_SHOW )
return;
if( panel )
zoom = panel->GetZoom();
else
zoom = ActiveScreen->GetZoom();
GRSetDrawMode( DC, draw_mode );
l_piste = PtDrawSegment->m_Width >> 1; /* l_piste = demi largeur piste */
/* coord de depart */
ux0 = PtDrawSegment->m_Start.x;
uy0 = PtDrawSegment->m_Start.y;
/* coord d'arrivee */
dx = PtDrawSegment->m_End.x;
dy = PtDrawSegment->m_End.y;
mode = DisplayOpt.DisplayDrawItems;
if( PtDrawSegment->m_Flags & FORCE_SKETCH )
mode = SKETCH;
if( l_piste < (L_MIN_DESSIN * zoom) )
mode = FILAIRE;
switch( PtDrawSegment->m_Shape ) PtDrawSegment->Draw( panel, DC, draw_mode );
{
case S_CIRCLE:
rayon = (int) hypot( (double) (dx - ux0), (double) (dy - uy0) );
if( mode == FILAIRE )
{
GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon, color );
}
else if( mode == SKETCH )
{
GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon - l_piste, color );
GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon + l_piste, color );
}
else
{
GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon, PtDrawSegment->m_Width, color );
}
break;
case S_ARC:
{
int StAngle, EndAngle;
rayon = (int) hypot( (double) (dx - ux0), (double) (dy - uy0) );
StAngle = (int) ArcTangente( dy - uy0, dx - ux0 );
EndAngle = StAngle + PtDrawSegment->m_Angle;
if( StAngle > EndAngle )
EXCHG( StAngle, EndAngle );
if( mode == FILAIRE )
GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, rayon, color );
else if( mode == SKETCH )
{
GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle,
rayon - l_piste, color );
GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle,
rayon + l_piste, color );
}
else
{
GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle,
rayon, PtDrawSegment->m_Width, color );
}
}
break;
default:
if( mode == FILAIRE )
GRLine( &panel->m_ClipBox, DC, ux0, uy0, dx, dy, 0, color );
else if( mode == SKETCH )
{
GRCSegm( &panel->m_ClipBox, DC, ux0, uy0, dx, dy,
PtDrawSegment->m_Width, color );
}
else
{
GRFillCSegm( &panel->m_ClipBox, DC, ux0, uy0, dx, dy,
PtDrawSegment->m_Width, color );
}
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