57 bool aDrawingDropShadows,
bool aFlipX,
bool aFlipY )
60 std::vector<wxString> cursorStrings;
70 cursorStrings.push_back(
DimensionLabel(
"x", temp.
x, aIuScale, aUnits ) );
71 cursorStrings.push_back(
DimensionLabel(
"y", temp.
y, aIuScale, aUnits ) );
88 if( aDrawingDropShadows )
110 static std::vector<TICK_FORMAT> tickFormats =
128 const auto pixelSpace = aTickSpace * aScale;
133 tickFormat = ( tickFormat + 1 ) % tickFormats.size();
137 return tickFormats[tickFormat];
163 int numTicks = (int) std::ceil( aLine.
EuclideanNorm() / tickSpace );
172 int shadowXoffset = 0;
174 if( aDrawingDropShadows )
182 const float adjust = 1.2f;
183 shadowXoffset *= adjust;
188 labelOffset = -labelOffset;
189 shadowXoffset = -shadowXoffset;
200 labelAttrs.
m_Angle = labelAngle;
203 labelOffset.
x -= shadowXoffset * labelAttrs.
m_Angle.
Cos();;
204 labelOffset.
y += shadowXoffset * labelAttrs.
m_Angle.
Sin();;
212 labelOffset.
x += shadowXoffset * labelAttrs.
m_Angle.
Cos();;
213 labelOffset.
y -= shadowXoffset * labelAttrs.
m_Angle.
Sin();;
219 viewport.
Inflate( majorTickLen * 2 );
224 for(
int i = 0; i < numTicks; ++i )
231 double length = aMinorTickLen;
232 bool drawLabel =
false;
246 gal->
DrawLine( tickPos, tickPos + tickLine.
Resize( length*isign ) );
250 wxString label =
DimensionLabel(
"", tickSpace * i, aIuScale, aUnits,
false );
268 double aTickLen,
int aNumDivisions,
bool aDrawingDropShadows )
272 const double backTickSpace = aLine.
EuclideanNorm() / aNumDivisions;
277 backTickVec = backTickVec.
Resize( aTickLen * isign );
282 viewport.
Inflate( aTickLen * 4 );
285 for(
int i = 0; i < aNumDivisions + 1; ++i )
287 const VECTOR2D backTickPos = aOrigin + aLine.
Resize( backTickSpace * i );
289 if( !viewport.
Contains( backTickPos ) )
293 gal->
DrawLine( backTickPos, backTickPos + backTickVec );
299 bool aFlipX,
bool aFlipY )
301 m_geomMgr( aGeomMgr ),
302 m_userUnits( userUnits ),
303 m_iuScale( aIuScale ),
350 if( drawingDropShadows )
371 drawBacksideTicks( aView, origin, rulerVec, majorTickLen, 2, drawingDropShadows );
constexpr const Vec & GetPosition() const
constexpr void SetMaximum()
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr bool Contains(const Vec &aPoint) const
constexpr const SizeVec & GetSize() const
A base class for most all the KiCad significant classes used in schematics and boards.
FONT is an abstract base class for both outline and stroke fonts.
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=false)
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttributes, const METRICS &aFontMetrics) const
Draw a string.
static const METRICS & Default()
Abstract interface for drawing on a 2D-surface.
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const COLOR4D & GetStrokeColor() const
Get the stroke color.
void PushDepth()
Store current drawing depth on the depth stack.
void ResetTextAttributes()
Reset text attributes to default styling.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
void SetTextMirrored(const bool aMirrored)
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual bool IsCairoEngine()
Return true if the GAL engine is a Cairo based type.
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
double GetMinDepth() const
void PopDepth()
Restore previously stored drawing depth for the depth stack.
double GetWorldScale() const
Get the world scale.
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
RULER_ITEM(const TWO_POINT_GEOMETRY_MANAGER &m_geomMgr, const EDA_IU_SCALE &aIuScale, EDA_UNITS userUnits, bool aFlipX, bool aFlipY)
Return the bounding box of the item covering all its layers.
const TWO_POINT_GEOMETRY_MANAGER & m_geomMgr
void ViewGetLayers(int aLayers[], int &aCount) const override
void ViewDraw(int aLayer, KIGFX::VIEW *aView) const override final
Draw the parts of the object belonging to layer aLayer.
const BOX2I ViewBBox() const override
Return the all the layers within the VIEW the object is painted on.
const EDA_IU_SCALE & m_iuScale
Represent a very simple geometry manager for items that have a start and end point.
VECTOR2I GetOrigin() const
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
bool IsMirroredX() const
Return true if view is flipped across the X axis.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
GR_TEXT_H_ALIGN_T m_Halign
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_180
@ LAYER_GP_OVERLAY
general purpose overlay
@ LAYER_AUX_ITEMS
Auxiliary items (guides, rule, etc)
@ LAYER_SELECT_OVERLAY
currently selected items overlay
KICOMMON_API bool IsImperialUnit(EDA_UNITS aUnit)
COLOR4D GetShadowColor(const COLOR4D &aColor)
wxString DimensionLabel(const wxString &prefix, double aVal, const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, bool aIncludeUnits=true)
Get a formatted string showing a dimension to a sane precision with an optional prefix and unit suffi...
void DrawTextNextToCursor(KIGFX::VIEW *aView, const VECTOR2D &aCursorPos, const VECTOR2D &aTextQuadrant, const std::vector< wxString > &aStrings, bool aDrawingDropShadows)
Draw strings next to the cursor.
TEXT_DIMS GetConstantGlyphHeight(KIGFX::GAL *aGal, int aRelativeSize=0)
Set the GAL glyph height to a constant scaled value, so that it always looks the same on screen.
static double getTickLineWidth(const TEXT_DIMS &textDims, bool aDrawingDropShadows)
static const double maxTickDensity
static TICK_FORMAT getTickFormatForScale(double aScale, double &aTickSpace, EDA_UNITS aUnits)
void drawBacksideTicks(KIGFX::VIEW *aView, const VECTOR2D &aOrigin, const VECTOR2D &aLine, double aTickLen, int aNumDivisions, bool aDrawingDropShadows)
Draw simple ticks on the back of a line such that the line is divided into n parts.
void drawTicksAlongLine(KIGFX::VIEW *aView, const VECTOR2D &aOrigin, const VECTOR2D &aLine, double aMinorTickLen, const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, bool aDrawingDropShadows)
Draw labelled ticks on a line.
static const double majorTickLengthFactor
static int getShadowLayer(KIGFX::GAL *aGal)
static const double midTickLengthFactor
static void drawCursorStrings(KIGFX::VIEW *aView, const VECTOR2D &aCursor, const VECTOR2D &aRulerVec, const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, bool aDrawingDropShadows, bool aFlipX, bool aFlipY)
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
@ NOT_USED
the 3d code uses this value
VECTOR2< int32_t > VECTOR2I