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

COLOR4D PreviewOverlayDefaultColor ()
 The default fill/stroke color of preview overlay items. More...
 
double PreviewOverlayFillAlpha ()
 The default alpha of overlay fills. More...
 
double PreviewOverlayDeemphAlpha (bool aDeemph=true)
 Default alpha of "de-emphasised" features (like previously locked-in lines. More...
 
COLOR4D PreviewOverlaySpecialAngleColor ()
 The colour of "special" angle overlay features. 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::GAL &aGal, 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 109 of file preview_utils.cpp.

References formatPreviewDimension().

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

111 {
112  wxString str;
113 
114  if( prefix.size() )
115  str << prefix << ": ";
116 
117  str << formatPreviewDimension( aVal, aUnits );
118  return str;
119 }
static wxString formatPreviewDimension(double aVal, EDA_UNITS_T aUnits)
void KIGFX::PREVIEW::DrawTextNextToCursor ( KIGFX::GAL aGal,
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 132 of file preview_utils.cpp.

References KIGFX::GAL::BitmapText(), KIGFX::GAL::GetGlyphSize(), KIGFX::GAL::GetWorldScale(), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, PreviewOverlayDeemphAlpha(), PreviewOverlayDefaultColor(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetStrokeColor(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

135 {
136  auto glyphSize = aGal.GetGlyphSize();
137 
138  const auto lineSpace = glyphSize.y * 0.2;
139  auto linePitch = glyphSize.y + lineSpace;
140 
141  // radius string goes on the right of the cursor centre line
142  // with a small horizontal offset (enough to keep clear of a
143  // system cursor if present)
144  auto textPos = aCursorPos;
145 
146  // if the text goes above the cursor, shift it up
147  if( aTextQuadrant.y > 0 )
148  {
149  textPos.y -= linePitch * ( aStrings.size() + 1 );
150  }
151 
152  if( aTextQuadrant.x < 0 )
153  {
155  textPos.x += 15.0 / aGal.GetWorldScale();
156  }
157  else
158  {
160  textPos.x -= 15.0 / aGal.GetWorldScale();
161  }
162 
163  aGal.SetStrokeColor( PreviewOverlayDefaultColor().WithAlpha(
164  PreviewOverlayDeemphAlpha( true ) ) );
165  aGal.SetIsFill( false );
166 
167  // write strings top-to-bottom
168  for( const auto& str : aStrings )
169  {
170  textPos.y += linePitch;
171  aGal.BitmapText( str, textPos, 0.0 );
172  }
173 }
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a text using a bitmap font.
double GetWorldScale() const
Get the world scale.
COLOR4D PreviewOverlayDefaultColor()
The default fill/stroke color of preview overlay items.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const VECTOR2D & GetGlyphSize() const
double PreviewOverlayDeemphAlpha(bool aDeemph=true)
Default alpha of "de-emphasised" features (like previously locked-in lines.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
double KIGFX::PREVIEW::PreviewOverlayDeemphAlpha ( bool  aDeemph = true)

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

Definition at line 41 of file preview_utils.cpp.

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

42 {
43  return aDeemph ? 0.5 : 1.0;
44 }
COLOR4D KIGFX::PREVIEW::PreviewOverlayDefaultColor ( )

The default fill/stroke color of preview overlay items.

Definition at line 29 of file preview_utils.cpp.

Referenced by drawArcWithHilight(), drawLineWithHilight(), KIGFX::PREVIEW::POLYGON_ITEM::drawPreviewShape(), DrawTextNextToCursor(), drawTicksAlongLine(), KIGFX::PREVIEW::ARC_ASSISTANT::ViewDraw(), and KIGFX::PREVIEW::RULER_ITEM::ViewDraw().

30 {
31  return COLOR4D( 1.0, 1.0, 1.0, 1.0 );
32 }
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
double KIGFX::PREVIEW::PreviewOverlayFillAlpha ( )

The default alpha of overlay fills.

Definition at line 35 of file preview_utils.cpp.

36 {
37  return 0.2;
38 }
COLOR4D KIGFX::PREVIEW::PreviewOverlaySpecialAngleColor ( )

The colour of "special" angle overlay features.

Definition at line 47 of file preview_utils.cpp.

Referenced by drawArcWithHilight(), and drawLineWithHilight().

48 {
49  return COLOR4D( 0.5, 1.0, 0.5, 1.0 );
50 }
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
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 122 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().

123 {
124  aHeight /= aGal.GetWorldScale();
125 
126  auto glyphSize = aGal.GetGlyphSize();
127  glyphSize = glyphSize * ( aHeight / glyphSize.y );
128  aGal.SetGlyphSize( glyphSize );
129 }
double GetWorldScale() const
Get the world scale.
const VECTOR2D & GetGlyphSize() const
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.