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 113 of file preview_utils.cpp.

References formatPreviewDimension().

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

115 {
116  wxString str;
117 
118  if( prefix.size() )
119  str << prefix << ": ";
120 
121  str << formatPreviewDimension( aVal, aUnits );
122  return str;
123 }
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 136 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().

139 {
140  auto glyphSize = aGal.GetGlyphSize();
141 
142  const auto lineSpace = glyphSize.y * 0.2;
143  auto linePitch = glyphSize.y + lineSpace;
144 
145  // radius string goes on the right of the cursor centre line
146  // with a small horizontal offset (enough to keep clear of a
147  // system cursor if present)
148  auto textPos = aCursorPos;
149 
150  // if the text goes above the cursor, shift it up
151  if( aTextQuadrant.y > 0 )
152  {
153  textPos.y -= linePitch * ( aStrings.size() + 1 );
154  }
155 
156  if( aTextQuadrant.x < 0 )
157  {
159  textPos.x += 15.0 / aGal.GetWorldScale();
160  }
161  else
162  {
164  textPos.x -= 15.0 / aGal.GetWorldScale();
165  }
166 
167  aGal.SetStrokeColor( PreviewOverlayDefaultColor().WithAlpha(
168  PreviewOverlayDeemphAlpha( true ) ) );
169  aGal.SetIsFill( false );
170 
171  // write strings top-to-bottom
172  for( const auto& str : aStrings )
173  {
174  textPos.y += linePitch;
175  aGal.BitmapText( str, textPos, 0.0 );
176  }
177 }
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 45 of file preview_utils.cpp.

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

46 {
47  return aDeemph ? 0.5 : 1.0;
48 }
COLOR4D KIGFX::PREVIEW::PreviewOverlayDefaultColor ( )

The default fill/stroke color of preview overlay items.

Definition at line 33 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().

34 {
35  return COLOR4D( 1.0, 1.0, 1.0, 1.0 );
36 }
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 39 of file preview_utils.cpp.

40 {
41  return 0.2;
42 }
COLOR4D KIGFX::PREVIEW::PreviewOverlaySpecialAngleColor ( )

The colour of "special" angle overlay features.

Definition at line 51 of file preview_utils.cpp.

Referenced by drawArcWithHilight(), and drawLineWithHilight().

52 {
53  return COLOR4D( 0.5, 1.0, 0.5, 1.0 );
54 }
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
aHeightthe height of the glyph, in pixels

Definition at line 126 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().

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