KiCad PCB EDA Suite
KIGFX::PREVIEW Namespace Reference

Classes

class  ARC_ASSISTANT
 Class SELECTION_AREA. More...
 
class  ARC_GEOM_MANAGER
 Class ARC_GEOM_MANAGER. More...
 
class  CENTRELINE_RECT_ITEM
 Class CENTRELINE_RECT_ITEM. More...
 
class  MULTISTEP_GEOM_MANAGER
 A geometry manager that works by accepting a sequence of points and advancing though stages of geometric construction with each point "locked in". More...
 
class  POLYGON_ITEM
 Class POLYGON_ITEM. More...
 
class  RULER_ITEM
 Class RULER_ITEM. More...
 
class  SELECTION_AREA
 Class SELECTION_AREA. More...
 
class  SIMPLE_OVERLAY_ITEM
 SIMPLE_OVERLAY_ITEM is class that represents a visual area drawn on a canvas, used to temporarily demarcate an area or show something on an overlay. More...
 
class  TWO_POINT_GEOMETRY_MANAGER
 Class TWO_POINT_GEOMETRY_MANAGER. More...
 

Functions

double PreviewOverlayDeemphAlpha (bool aDeemph=true)
 Default alpha of "de-emphasised" features (like previously locked-in lines. More...
 
wxString DimensionLabel (const wxString &prefix, double aVal, EDA_UNITS_T aUnits)
 Get a formatted string showing a dimension to a sane precision with an optional prefix and unit suffix. More...
 
void SetConstantGlyphHeight (KIGFX::GAL &aGal, double aHeight)
 Set the GAL glyph height to a constant scaled value, so that it always looks the same on screen. More...
 
void DrawTextNextToCursor (KIGFX::VIEW *aView, const VECTOR2D &aCursorPos, const VECTOR2D &aTextQuadrant, const std::vector< wxString > &aStrings)
 Draw strings next to the cursor. More...
 

Function Documentation

wxString KIGFX::PREVIEW::DimensionLabel ( const wxString &  prefix,
double  aVal,
EDA_UNITS_T  aUnits 
)

Get a formatted string showing a dimension to a sane precision with an optional prefix and unit suffix.

Definition at line 92 of file preview_utils.cpp.

References formatPreviewDimension().

Referenced by drawCursorStrings(), drawTicksAlongLine(), and KIGFX::PREVIEW::ARC_ASSISTANT::ViewDraw().

94 {
95  wxString str;
96 
97  if( prefix.size() )
98  str << prefix << ": ";
99 
100  str << formatPreviewDimension( aVal, aUnits );
101  return str;
102 }
static wxString formatPreviewDimension(double aVal, EDA_UNITS_T aUnits)
void KIGFX::PREVIEW::DrawTextNextToCursor ( KIGFX::VIEW aView,
const VECTOR2D aCursorPos,
const VECTOR2D aTextQuadrant,
const std::vector< wxString > &  aStrings 
)

Draw strings next to the cursor.

Parameters
aGalthe GAL to draw on
aCursorPosthe position of the cursor to draw next to
aTextQuadranta vector pointing to the quadrant to draw the text in
aStringslist of strings to draw, top to bottom

Definition at line 115 of file preview_utils.cpp.

References KIGFX::VIEW::GetGAL(), KIGFX::GAL::GetGlyphSize(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, LAYER_AUX_ITEMS, PreviewOverlayDeemphAlpha(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by drawCursorStrings(), and KIGFX::PREVIEW::ARC_ASSISTANT::ViewDraw().

118 {
119  auto gal = aView->GetGAL();
120  auto glyphSize = gal->GetGlyphSize();
121  auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( aView->GetPainter()->GetSettings() );
122 
123  const auto lineSpace = glyphSize.y * 0.2;
124  auto linePitch = glyphSize.y + lineSpace;
125 
126  // radius string goes on the right of the cursor centre line
127  // with a small horizontal offset (enough to keep clear of a
128  // system cursor if present)
129  auto textPos = aCursorPos;
130 
131  // if the text goes above the cursor, shift it up
132  if( aTextQuadrant.y > 0 )
133  {
134  textPos.y -= linePitch * ( aStrings.size() + 1 );
135  }
136 
137  if( aTextQuadrant.x < 0 )
138  {
139  gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
140  textPos.x += 15.0 / gal->GetWorldScale();
141  }
142  else
143  {
144  gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
145  textPos.x -= 15.0 / gal->GetWorldScale();
146  }
147 
148  gal->SetStrokeColor( rs->GetLayerColor( LAYER_AUX_ITEMS ).WithAlpha(
149  PreviewOverlayDeemphAlpha( true ) ) );
150  gal->SetIsFill( false );
151 
152  // write strings top-to-bottom
153  for( const auto& str : aStrings )
154  {
155  textPos.y += linePitch;
156  gal->BitmapText( str, textPos, 0.0 );
157  }
158 }
Class PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:62
Auxillary items (guides, rule, etc)
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:177
const VECTOR2D & GetGlyphSize() const
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
double PreviewOverlayDeemphAlpha(bool aDeemph=true)
Default alpha of "de-emphasised" features (like previously locked-in lines.
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
double KIGFX::PREVIEW::PreviewOverlayDeemphAlpha ( bool  aDeemph = true)

Default alpha of "de-emphasised" features (like previously locked-in lines.

Definition at line 30 of file preview_utils.cpp.

Referenced by drawLineWithHilight(), DrawTextNextToCursor(), drawTicksAlongLine(), and KIGFX::PREVIEW::RULER_ITEM::ViewDraw().

31 {
32  return aDeemph ? 0.5 : 1.0;
33 }
void KIGFX::PREVIEW::SetConstantGlyphHeight ( KIGFX::GAL aGal,
double  aHeight 
)

Set the GAL glyph height to a constant scaled value, so that it always looks the same on screen.

Parameters
aGalthe GAL to draw on
aHeightthe height of the glyph, in pixels

Definition at line 105 of file preview_utils.cpp.

References KIGFX::GAL::GetGlyphSize(), KIGFX::GAL::GetWorldScale(), and KIGFX::GAL::SetGlyphSize().

Referenced by KIGFX::PREVIEW::ARC_ASSISTANT::ViewDraw(), and KIGFX::PREVIEW::RULER_ITEM::ViewDraw().

106 {
107  aHeight /= aGal.GetWorldScale();
108 
109  auto glyphSize = aGal.GetGlyphSize();
110  glyphSize = glyphSize * ( aHeight / glyphSize.y );
111  aGal.SetGlyphSize( glyphSize );
112 }
double GetWorldScale() const
Get the world scale.
const VECTOR2D & GetGlyphSize() const
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.