KiCad PCB EDA Suite
page_layout_graphic_items.cpp File Reference

description of graphic items and texts to build a title block More...

#include <fctsys.h>
#include <eda_rect.h>
#include <draw_graphic_text.h>
#include <worksheet.h>
#include <title_block.h>
#include <worksheet_shape_builder.h>
#include <worksheet_dataitem.h>
#include <polygon_test_point_inside.h>

Go to the source code of this file.

Functions

static double getScaleFromZoom (wxDC *aDC)
 
void drawMarker (EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aPos, int aSize, bool aEndPointShape=false)
 

Detailed Description

description of graphic items and texts to build a title block

Definition in file page_layout_graphic_items.cpp.

Function Documentation

void drawMarker ( EDA_RECT aClipBox,
wxDC *  aDC,
const wxPoint aPos,
int  aSize,
bool  aEndPointShape = false 
)
inline

Definition at line 96 of file page_layout_graphic_items.cpp.

References GREEN, GRFilledCircle(), GRFilledRect(), wxPoint::x, and wxPoint::y.

Referenced by WS_DRAW_ITEM_LIST::Draw().

98 {
99  int markerHalfSize = aSize/2;
100 
101  if( aEndPointShape )
102  GRFilledCircle( aClipBox, aDC, aPos.x, aPos.y, markerHalfSize,
103  0, GREEN, GREEN );
104  else
105  GRFilledRect( aClipBox, aDC,
106  aPos.x - markerHalfSize, aPos.y - markerHalfSize,
107  aPos.x + markerHalfSize, aPos.y + markerHalfSize,
108  0, GREEN, GREEN );
109 }
void GRFilledRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:1043
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:778
Definition: colors.h:58
static double getScaleFromZoom ( wxDC *  aDC)
static

Definition at line 72 of file page_layout_graphic_items.cpp.

References WORKSHEET_DATAITEM::m_WSunits2Iu, max, min, and scale.

Referenced by WS_DRAW_ITEM_LIST::Draw(), WS_DRAW_ITEM_LINE::HitTestEndPoint(), WS_DRAW_ITEM_RECT::HitTestEndPoint(), WS_DRAW_ITEM_LINE::HitTestStartPoint(), WS_DRAW_ITEM_POLYGON::HitTestStartPoint(), WS_DRAW_ITEM_RECT::HitTestStartPoint(), WS_DRAW_ITEM_TEXT::HitTestStartPoint(), and WS_DRAW_ITEM_BITMAP::HitTestStartPoint().

73 {
74  double x, y;
75  aDC->GetUserScale( &x, &y );
76 
77  double scale = (x + y ) / 2; // should be equal, but if not best we can do is average
78 
79  double fscale = WORKSHEET_DATAITEM::m_WSunits2Iu * scale;
80  double zscale = 20.0/ fscale; // The 20.0 factor is chosen for best results
81  // (fix the zoom level to have a zscale > 1)
82 
83  // clamp scaling factor:
84  zscale = std::max( 1.0, zscale ); // never smaller than actual size
85  zscale = std::min( 10.0, zscale ); // should be enough to make item visible
86 
87  return zscale;
88 }
static double m_WSunits2Iu
const int scale
#define max(a, b)
Definition: auxiliary.h:86
#define min(a, b)
Definition: auxiliary.h:85