Added selection boxes for texts.
This commit is contained in:
parent
6af09fedda
commit
d73d153665
|
@ -223,3 +223,15 @@ const BOX2I TEXTE_PCB::ViewBBox() const
|
||||||
return BOX2I( rect.GetOrigin(), rect.GetSize() );
|
return BOX2I( rect.GetOrigin(), rect.GetSize() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TEXTE_PCB::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||||
|
{
|
||||||
|
// Layer that simply displays the text
|
||||||
|
aLayers[0] = m_Layer;
|
||||||
|
|
||||||
|
// On the general purpose overlay there is a selection box displayed
|
||||||
|
aLayers[1] = ITEM_GAL_LAYER( GP_OVERLAY );
|
||||||
|
|
||||||
|
aCount = 2;
|
||||||
|
}
|
||||||
|
|
|
@ -121,12 +121,15 @@ public:
|
||||||
|
|
||||||
EDA_ITEM* Clone() const;
|
EDA_ITEM* Clone() const;
|
||||||
|
|
||||||
|
/// @copydoc VIEW_ITEM::ViewBBox()
|
||||||
|
virtual const BOX2I ViewBBox() const;
|
||||||
|
|
||||||
|
/// @copydoc VIEW_ITEM::ViewGetLayers()
|
||||||
|
virtual void ViewGetLayers( int aLayers[], int& aCount ) const;
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
virtual void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
|
virtual void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// @copydoc VIEW_ITEM::ViewBBox()
|
|
||||||
virtual const BOX2I ViewBBox() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // #define CLASS_PCB_TEXT_H
|
#endif // #define CLASS_PCB_TEXT_H
|
||||||
|
|
|
@ -456,5 +456,8 @@ void TEXTE_MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
aCount = 1;
|
// On the general purpose overlay there is a selection box displayed
|
||||||
|
aLayers[1] = ITEM_GAL_LAYER( GP_OVERLAY );
|
||||||
|
|
||||||
|
aCount = 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,6 @@ public:
|
||||||
return wxT( "MTEXT" );
|
return wxT( "MTEXT" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString GetSelectMenuText() const;
|
wxString GetSelectMenuText() const;
|
||||||
|
|
||||||
BITMAP_DEF GetMenuImage() const { return footprint_text_xpm; }
|
BITMAP_DEF GetMenuImage() const { return footprint_text_xpm; }
|
||||||
|
|
|
@ -224,7 +224,7 @@ bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCB_TEXT_T:
|
case PCB_TEXT_T:
|
||||||
draw( (TEXTE_PCB*) aItem );
|
draw( (TEXTE_PCB*) aItem, aLayer );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCB_MODULE_TEXT_T:
|
case PCB_MODULE_TEXT_T:
|
||||||
|
@ -662,65 +662,55 @@ void PCB_PAINTER::draw( const MODULE* aModule )
|
||||||
{
|
{
|
||||||
// For modules we have to draw a selection box if needed
|
// For modules we have to draw a selection box if needed
|
||||||
if( aModule->IsSelected() )
|
if( aModule->IsSelected() )
|
||||||
{
|
drawSelectionBox( aModule );
|
||||||
BOX2I boundingBox = aModule->ViewBBox();
|
|
||||||
|
|
||||||
m_gal->SetIsStroke( false );
|
|
||||||
m_gal->SetIsFill( true );
|
|
||||||
m_gal->SetFillColor( COLOR4D( 1.0, 1.0, 1.0, 0.5 ) );
|
|
||||||
m_gal->DrawRectangle( boundingBox.GetOrigin(), boundingBox.GetEnd() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_PAINTER::draw( const TEXTE_PCB* aText )
|
void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer )
|
||||||
{
|
{
|
||||||
if( aText->GetText().Length() == 0 )
|
if( aLayer == ITEM_GAL_LAYER( GP_OVERLAY ) )
|
||||||
return;
|
{
|
||||||
|
if( aText->IsSelected() )
|
||||||
|
drawSelectionBox( aText );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( aText->GetText().Length() == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
COLOR4D strokeColor = GetColor( NULL, aText->GetLayer() );
|
COLOR4D strokeColor = GetColor( NULL, aText->GetLayer() );
|
||||||
VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y );
|
VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y );
|
||||||
double orientation = aText->GetOrientation() * M_PI / 1800.0;
|
double orientation = aText->GetOrientation() * M_PI / 1800.0;
|
||||||
|
|
||||||
m_gal->SetStrokeColor( strokeColor );
|
m_gal->SetStrokeColor( strokeColor );
|
||||||
m_gal->SetLineWidth( aText->GetThickness() );
|
m_gal->SetLineWidth( aText->GetThickness() );
|
||||||
m_gal->SetTextAttributes( aText );
|
m_gal->SetTextAttributes( aText );
|
||||||
m_gal->StrokeText( std::string( aText->GetText().mb_str() ), position, orientation );
|
m_gal->StrokeText( std::string( aText->GetText().mb_str() ), position, orientation );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
|
void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
|
||||||
{
|
{
|
||||||
if( aText->GetLength() == 0 )
|
if( aLayer == ITEM_GAL_LAYER( GP_OVERLAY ) )
|
||||||
return;
|
|
||||||
|
|
||||||
COLOR4D strokeColor = GetColor( NULL, aLayer );
|
|
||||||
VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y);
|
|
||||||
double orientation = aText->GetDrawRotation() * M_PI / 1800.0;
|
|
||||||
|
|
||||||
m_gal->PushDepth();
|
|
||||||
|
|
||||||
/*if(aText->IsSelected())
|
|
||||||
{
|
{
|
||||||
EDA_RECT bb (aText->GetBoundingBox());
|
if( aText->IsSelected() )
|
||||||
VECTOR2D s (bb.GetOrigin());
|
drawSelectionBox( aText );
|
||||||
VECTOR2D e (bb.GetEnd());
|
}
|
||||||
m_gal->SetFillColor( COLOR4D (1.0, 1.0, 1.0, 0.3) );
|
else
|
||||||
m_gal->SetStrokeColor( COLOR4D (1.0, 1.0, 1.0, 0.5) );
|
{
|
||||||
m_gal->SetIsFill(true);
|
if( aText->GetLength() == 0 )
|
||||||
m_gal->SetIsStroke(true);
|
return;
|
||||||
m_gal->SetLineWidth(0);
|
|
||||||
m_gal->DrawRectangle(s, e);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
m_gal->AdvanceDepth();
|
|
||||||
|
|
||||||
m_gal->SetStrokeColor( strokeColor );
|
COLOR4D strokeColor = GetColor( NULL, aLayer );
|
||||||
m_gal->SetLineWidth( aText->GetThickness() );
|
VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y);
|
||||||
m_gal->SetTextAttributes( aText );
|
double orientation = aText->GetDrawRotation() * M_PI / 1800.0;
|
||||||
m_gal->StrokeText( std::string( aText->GetText().mb_str() ), position, orientation );
|
|
||||||
|
|
||||||
m_gal->PopDepth();
|
m_gal->SetStrokeColor( strokeColor );
|
||||||
|
m_gal->SetLineWidth( aText->GetThickness() );
|
||||||
|
m_gal->SetTextAttributes( aText );
|
||||||
|
m_gal->StrokeText( std::string( aText->GetText().mb_str() ), position, orientation );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -796,7 +786,8 @@ void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone )
|
||||||
|
|
||||||
void PCB_PAINTER::draw( const DIMENSION* aDimension )
|
void PCB_PAINTER::draw( const DIMENSION* aDimension )
|
||||||
{
|
{
|
||||||
COLOR4D strokeColor = GetColor( NULL, aDimension->GetLayer() );
|
int layer = aDimension->GetLayer();
|
||||||
|
COLOR4D strokeColor = GetColor( NULL, layer );
|
||||||
|
|
||||||
m_gal->SetStrokeColor( strokeColor );
|
m_gal->SetStrokeColor( strokeColor );
|
||||||
m_gal->SetIsFill( false );
|
m_gal->SetIsFill( false );
|
||||||
|
@ -805,15 +796,17 @@ void PCB_PAINTER::draw( const DIMENSION* aDimension )
|
||||||
|
|
||||||
// Draw an arrow
|
// Draw an arrow
|
||||||
m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_crossBarF ) );
|
m_gal->DrawLine( VECTOR2D( aDimension->m_crossBarO ), VECTOR2D( aDimension->m_crossBarF ) );
|
||||||
m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineGO ), VECTOR2D( aDimension->m_featureLineGF ) );
|
m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineGO ),
|
||||||
m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineDO ), VECTOR2D( aDimension->m_featureLineDF ) );
|
VECTOR2D( aDimension->m_featureLineGF ) );
|
||||||
|
m_gal->DrawLine( VECTOR2D( aDimension->m_featureLineDO ),
|
||||||
|
VECTOR2D( aDimension->m_featureLineDF ) );
|
||||||
m_gal->DrawLine( VECTOR2D( aDimension->m_arrowD1O ), VECTOR2D( aDimension->m_arrowD1F ) );
|
m_gal->DrawLine( VECTOR2D( aDimension->m_arrowD1O ), VECTOR2D( aDimension->m_arrowD1F ) );
|
||||||
m_gal->DrawLine( VECTOR2D( aDimension->m_arrowD2O ), VECTOR2D( aDimension->m_arrowD2F ) );
|
m_gal->DrawLine( VECTOR2D( aDimension->m_arrowD2O ), VECTOR2D( aDimension->m_arrowD2F ) );
|
||||||
m_gal->DrawLine( VECTOR2D( aDimension->m_arrowG1O ), VECTOR2D( aDimension->m_arrowG1F ) );
|
m_gal->DrawLine( VECTOR2D( aDimension->m_arrowG1O ), VECTOR2D( aDimension->m_arrowG1F ) );
|
||||||
m_gal->DrawLine( VECTOR2D( aDimension->m_arrowG2O ), VECTOR2D( aDimension->m_arrowG2F ) );
|
m_gal->DrawLine( VECTOR2D( aDimension->m_arrowG2O ), VECTOR2D( aDimension->m_arrowG2F ) );
|
||||||
|
|
||||||
// Draw text
|
// Draw text
|
||||||
draw( &aDimension->Text() );
|
draw( &aDimension->Text(), layer );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -853,3 +846,14 @@ void PCB_PAINTER::draw( const PCB_TARGET* aTarget )
|
||||||
|
|
||||||
m_gal->Restore();
|
m_gal->Restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PCB_PAINTER::drawSelectionBox( const VIEW_ITEM* aItem ) const
|
||||||
|
{
|
||||||
|
BOX2I boundingBox = aItem->ViewBBox();
|
||||||
|
|
||||||
|
m_gal->SetIsStroke( false );
|
||||||
|
m_gal->SetIsFill( true );
|
||||||
|
m_gal->SetFillColor( COLOR4D( 1.0, 1.0, 1.0, 0.5 ) );
|
||||||
|
m_gal->DrawRectangle( boundingBox.GetOrigin(), boundingBox.GetEnd() );
|
||||||
|
}
|
||||||
|
|
|
@ -142,11 +142,14 @@ protected:
|
||||||
void draw( const D_PAD*, int );
|
void draw( const D_PAD*, int );
|
||||||
void draw( const DRAWSEGMENT* );
|
void draw( const DRAWSEGMENT* );
|
||||||
void draw( const MODULE* );
|
void draw( const MODULE* );
|
||||||
void draw( const TEXTE_PCB* );
|
void draw( const TEXTE_PCB*, int );
|
||||||
void draw( const TEXTE_MODULE*, int );
|
void draw( const TEXTE_MODULE*, int );
|
||||||
void draw( const ZONE_CONTAINER* );
|
void draw( const ZONE_CONTAINER* );
|
||||||
void draw( const DIMENSION* );
|
void draw( const DIMENSION* );
|
||||||
void draw( const PCB_TARGET* );
|
void draw( const PCB_TARGET* );
|
||||||
|
|
||||||
|
/// Draws a white semitransparent box indicating an item as selected
|
||||||
|
void drawSelectionBox( const VIEW_ITEM* aItem ) const;
|
||||||
};
|
};
|
||||||
} // namespace KiGfx
|
} // namespace KiGfx
|
||||||
|
|
||||||
|
|
|
@ -50,8 +50,8 @@ class GENERAL_COLLECTOR;
|
||||||
class SELECTION_TOOL : public TOOL_INTERACTIVE
|
class SELECTION_TOOL : public TOOL_INTERACTIVE
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SELECTION_TOOL ();
|
SELECTION_TOOL();
|
||||||
~SELECTION_TOOL ();
|
~SELECTION_TOOL();
|
||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
int Main( TOOL_EVENT& aEvent );
|
int Main( TOOL_EVENT& aEvent );
|
||||||
|
|
Loading…
Reference in New Issue