KiCad PCB EDA Suite
page_layout_graphic_items.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 1992-2013 Jean-Pierre Charras <jp.charras at wanadoo.fr>.
5  * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
30 /*
31  * the class WORKSHEET_DATAITEM (and WORKSHEET_DATAITEM_TEXT) defines
32  * a basic shape of a page layout ( frame references and title block )
33  * Basic shapes are line, rect and texts
34  * the WORKSHEET_DATAITEM coordinates units is the mm, and are relative to
35  * one of 4 page corners.
36  *
37  * These items cannot be drawn or plot "as this". they should be converted
38  * to a "draw list" (WS_DRAW_ITEM_BASE and derived items)
39 
40  * The list of these items is stored in a WORKSHEET_LAYOUT instance.
41  *
42  * When building the draw list:
43  * the WORKSHEET_LAYOUT is used to create a WS_DRAW_ITEM_LIST
44  * coordinates are converted to draw/plot coordinates.
45  * texts are expanded if they contain format symbols.
46  * Items with m_RepeatCount > 1 are created m_RepeatCount times
47  *
48  * the WORKSHEET_LAYOUT is created only once.
49  * the WS_DRAW_ITEM_LIST is created each time the page layout is plotted/drawn
50  *
51  * the WORKSHEET_LAYOUT instance is created from a S expression which
52  * describes the page layout (can be the default page layout or a custom file).
53  */
54 
55 #include <fctsys.h>
56 #include <eda_rect.h>
57 #include <draw_graphic_text.h>
58 #include <worksheet.h>
59 #include <title_block.h>
61 #include <worksheet_dataitem.h>
63 
64 /* a helper function to calculate a marker size scaling factor from zoom level
65  * when one need a "constant" size to draw an item whatever the zoom level
66  * the scaling factor is clamped between 1.0 to 10.0 to avoid ugly drawings
67  * when the factor is ti high (1.0 is the "actual" item size)
68  * Note:
69  * Only the page layout editor uses the marker size.
70  * Other editors do not use or draw markers
71  */
72 static double getScaleFromZoom( wxDC* aDC )
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 }
89 
90 
91 /* a helper function to draw graphic symbols at start point or end point of
92  * an item.
93  * The start point symbol is a filled rectangle
94  * The start point symbol is a filled circle
95  */
96 inline void drawMarker( EDA_RECT* aClipBox, wxDC* aDC,
97  const wxPoint& aPos, int aSize, bool aEndPointShape = false )
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 }
110 
111 
112 /* Draws the item list created by BuildWorkSheetGraphicList
113  * aClipBox = the clipping rect, or NULL if no clipping
114  * aDC = the current Device Context
115  * The not selected items are drawn first (most of items)
116  * The selected items are drawn after (usually 0 or 1)
117  * to be sure they are seen, even for overlapping items
118  */
119 void WS_DRAW_ITEM_LIST::Draw( EDA_RECT* aClipBox, wxDC* aDC )
120 {
121  // The not selected items are drawn first (most of items)
122  for( WS_DRAW_ITEM_BASE* item = GetFirst(); item; item = GetNext() )
123  {
124  if( item->GetParent() && item->GetParent()->IsSelected() )
125  continue;
126 
127  item->DrawWsItem( aClipBox, aDC );
128  }
129 
130  // The selected items are drawn after (usually 0 or 1)
131  int markerSize = WORKSHEET_DATAITEM::GetMarkerSizeUi( getScaleFromZoom( aDC ) );
132 
133  for( WS_DRAW_ITEM_BASE* item = GetFirst(); item; item = GetNext() )
134  {
135  if( !item->GetParent() || !item->GetParent()->IsSelected() )
136  continue;
137 
138  item->DrawWsItem( aClipBox, aDC );
139 
140  if( !markerSize )
141  continue;
142 
143  switch( item->GetType() )
144  {
146  {
147  WS_DRAW_ITEM_LINE* line = (WS_DRAW_ITEM_LINE*) item;
148  drawMarker( aClipBox, aDC, line->GetStart(), markerSize );
149  drawMarker( aClipBox, aDC, line->GetEnd(), markerSize, true );
150  }
151  break;
152 
154  {
155  WS_DRAW_ITEM_RECT* rect = (WS_DRAW_ITEM_RECT*) item;
156  drawMarker( aClipBox, aDC, rect->GetStart(), markerSize );
157  drawMarker( aClipBox, aDC, rect->GetEnd(), markerSize, true );
158  }
159  break;
160 
162  {
163  WS_DRAW_ITEM_TEXT* text = (WS_DRAW_ITEM_TEXT*) item;
164  drawMarker( aClipBox, aDC, text->GetTextPos(), markerSize );
165  }
166  break;
167 
169  {
171  drawMarker( aClipBox, aDC, poly->GetPosition(), markerSize );
172  }
173  break;
174 
176  {
177  WS_DRAW_ITEM_BITMAP* bitmap = (WS_DRAW_ITEM_BITMAP*) item;
178  drawMarker( aClipBox, aDC, bitmap->GetPosition(), markerSize );
179  }
180  break;
181  }
182  }
183 }
184 
185 
187  wxString& aText, wxPoint aPos, wxSize aSize,
188  int aPenWidth, COLOR4D aColor,
189  bool aItalic, bool aBold ) :
190  WS_DRAW_ITEM_BASE( aParent, wsg_text, aColor ), EDA_TEXT( aText )
191 {
192  SetTextPos( aPos );
193  SetTextSize( aSize );
194  SetThickness( aPenWidth );
195  SetItalic( aItalic );
196  SetBold( aBold );
197 }
198 
199 
200 void WS_DRAW_ITEM_TEXT::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
201  GR_DRAWMODE aDrawMode, COLOR4D aColor )
202 {
203  Draw( aClipBox, aDC, aOffset,
204  aColor == COLOR4D::UNSPECIFIED ? GetColor() : aColor,
205  aDrawMode == UNSPECIFIED_DRAWMODE ? GR_COPY : aDrawMode,
206  FILLED, COLOR4D::UNSPECIFIED );
207 }
208 
209 
210 bool WS_DRAW_ITEM_TEXT::HitTest( const wxPoint& aPosition) const
211 {
212  return EDA_TEXT::TextHitTest( aPosition, 0 );
213 }
214 
215 
216 bool WS_DRAW_ITEM_TEXT::HitTest( const EDA_RECT& aRect ) const
217 {
218  return EDA_TEXT::TextHitTest( aRect, 0, 0 );
219 }
220 
221 
222 bool WS_DRAW_ITEM_TEXT::HitTestStartPoint( wxDC *aDC, const wxPoint& aPosition )
223 {
224  wxPoint pos = GetTextPos();
225  int marker_size = WORKSHEET_DATAITEM::GetMarkerSizeUi( getScaleFromZoom( aDC ) );
226 
227  if( std::abs( pos.x - aPosition.x) <= marker_size / 2 &&
228  std::abs( pos.y - aPosition.y) <= marker_size / 2 )
229  return true;
230 
231  return false;
232 }
233 
234 
235 void WS_DRAW_ITEM_POLYGON::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
236  GR_DRAWMODE aDrawMode, COLOR4D aColor )
237 {
238  std::vector<wxPoint> points_moved;
239  wxPoint *points;
240 
241  if( aOffset.x || aOffset.y )
242  {
243  for( auto point: m_Corners )
244  points_moved.push_back( point + aOffset );
245  points = &points_moved[0];
246  }
247  else
248  {
249  points = &m_Corners[0];
250  }
251 
252  auto color = ( aColor == COLOR4D::UNSPECIFIED ) ? GetColor() : aColor;
253 
254  GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ? GR_COPY : aDrawMode ) );
255  GRPoly( aClipBox, aDC,
256  m_Corners.size(), points,
257  IsFilled() ? FILLED_SHAPE : NO_FILL,
258  GetPenWidth(),
259  color, color );
260  GRSetDrawMode( aDC, GR_COPY );
261 }
262 
263 
264 bool WS_DRAW_ITEM_POLYGON::HitTest( const wxPoint& aPosition) const
265 {
266  return TestPointInsidePolygon( &m_Corners[0],
267  m_Corners.size(), aPosition );
268 }
269 
270 
271 bool WS_DRAW_ITEM_POLYGON::HitTest( const EDA_RECT& aRect ) const
272 {
273  // Intersection of two polygons is nontrivial. Test if the rectangle intersects
274  // each line, instead.
275 
276  if( m_Corners.size() < 2 )
277  return false;
278 
279  for( size_t i = 1; i < m_Corners.size(); ++i )
280  {
281  if( aRect.Intersects( m_Corners[i - 1], m_Corners[i] ) )
282  return true;
283  }
284 
285  return false;
286 }
287 
288 
289 bool WS_DRAW_ITEM_POLYGON::HitTestStartPoint( wxDC *aDC, const wxPoint& aPosition )
290 {
291  wxPoint pos = GetPosition();
292  int marker_size = WORKSHEET_DATAITEM::GetMarkerSizeUi( getScaleFromZoom( aDC ) );
293 
294  if( std::abs( pos.x - aPosition.x) <= marker_size / 2 &&
295  std::abs( pos.y - aPosition.y) <= marker_size / 2 )
296  return true;
297 
298  return false;
299 }
300 
301 
302 void WS_DRAW_ITEM_RECT::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
303  GR_DRAWMODE aDrawMode, COLOR4D aColor )
304 {
305  GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ? GR_COPY : aDrawMode ) );
306  GRRect( aClipBox, aDC,
307  GetStart().x + aOffset.x, GetStart().y + aOffset.y,
308  GetEnd().x + aOffset.x, GetEnd().y + aOffset.y,
309  GetPenWidth(),
310  ( aColor == COLOR4D::UNSPECIFIED ) ? GetColor() : aColor );
311  GRSetDrawMode( aDC, GR_COPY );
312 }
313 
314 
315 bool WS_DRAW_ITEM_RECT::HitTest( const wxPoint& aPosition ) const
316 {
317  int dist = GetPenWidth()/2;
318  wxPoint start = GetStart();
319  wxPoint end;
320  end.x = GetEnd().x;
321  end.y = start.y;
322 
323  // Upper line
324  if( TestSegmentHit( aPosition, start, end, dist ) )
325  return true;
326 
327  // Right line
328  start = end;
329  end.y = GetEnd().y;
330  if( TestSegmentHit( aPosition, start, end, dist ) )
331  return true;
332 
333  // lower line
334  start = end;
335  end.x = GetStart().x;
336  if( TestSegmentHit( aPosition, start, end, dist ) )
337  return true;
338 
339  // left line
340  start = end;
341  end = GetStart();
342  if( TestSegmentHit( aPosition, start, end, dist ) )
343  return true;
344 
345  return false;
346 }
347 
348 
349 bool WS_DRAW_ITEM_RECT::HitTest( const EDA_RECT& aRect ) const
350 {
351  wxPoint start = GetStart();
352  wxPoint end;
353  end.x = GetEnd().x;
354  end.y = start.y;
355 
356  // Upper line
357  if( aRect.Intersects( start, end ) )
358  return true;
359 
360  // Right line
361  start = end;
362  end.y = GetEnd().y;
363  if( aRect.Intersects( start, end ) )
364  return true;
365 
366  // lower line
367  start = end;
368  end.x = GetStart().x;
369  if( aRect.Intersects( start, end ) )
370  return true;
371 
372  // left line
373  start = end;
374  end = GetStart();
375  if( aRect.Intersects( start, end ) )
376  return true;
377 
378  return false;
379 }
380 
381 
382 bool WS_DRAW_ITEM_RECT::HitTestStartPoint( wxDC *aDC, const wxPoint& aPosition )
383 {
384  wxPoint dist = GetStart() - aPosition;
385  int marker_size = WORKSHEET_DATAITEM::GetMarkerSizeUi( getScaleFromZoom( aDC ) );
386 
387  if( std::abs( dist.x) <= marker_size / 2 &&
388  std::abs( dist.y) <= marker_size / 2 )
389  return true;
390 
391  return false;
392 }
393 
394 
395 bool WS_DRAW_ITEM_RECT::HitTestEndPoint( wxDC *aDC, const wxPoint& aPosition )
396 {
397  wxPoint pos = GetEnd();
398  int marker_size = WORKSHEET_DATAITEM::GetMarkerSizeUi( getScaleFromZoom( aDC ) );
399 
400  int dist = (int) hypot( pos.x - aPosition.x, pos.y - aPosition.y );
401 
402  if( dist <= marker_size / 2 )
403  return true;
404 
405  return false;
406 }
407 
408 
409 void WS_DRAW_ITEM_LINE::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
410  GR_DRAWMODE aDrawMode, COLOR4D aColor )
411 {
412  GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ) ? GR_COPY : aDrawMode );
413  GRLine( aClipBox, aDC, GetStart() + aOffset, GetEnd() + aOffset,
414  GetPenWidth(),
415  ( aColor == COLOR4D::UNSPECIFIED ) ? GetColor() : aColor );
416  GRSetDrawMode( aDC, GR_COPY );
417 }
418 
419 
420 bool WS_DRAW_ITEM_LINE::HitTest( const wxPoint& aPosition) const
421 {
422  return TestSegmentHit( aPosition, GetStart(), GetEnd(), GetPenWidth()/2 );
423 }
424 
425 
426 bool WS_DRAW_ITEM_LINE::HitTest( const EDA_RECT& aRect ) const
427 {
428  return aRect.Intersects( GetStart(), GetEnd() );
429 }
430 
431 
432 bool WS_DRAW_ITEM_LINE::HitTestStartPoint( wxDC *aDC, const wxPoint& aPosition )
433 {
434  wxPoint dist = GetStart() - aPosition;
435  int marker_size = WORKSHEET_DATAITEM::GetMarkerSizeUi( getScaleFromZoom( aDC ) );
436 
437  if( std::abs( dist.x) <= marker_size / 2 &&
438  std::abs( dist.y) <= marker_size / 2 )
439  return true;
440 
441  return false;
442 }
443 
444 
445 bool WS_DRAW_ITEM_LINE::HitTestEndPoint( wxDC *aDC, const wxPoint& aPosition )
446 {
447  wxPoint dist = GetEnd() - aPosition;
448  int marker_size = WORKSHEET_DATAITEM::GetMarkerSizeUi( getScaleFromZoom( aDC ) );
449 
450  if( std::abs( dist.x) <= marker_size / 2 &&
451  std::abs( dist.y) <= marker_size / 2 )
452  return true;
453 
454  return false;
455 }
456 
457 
458 void WS_DRAW_ITEM_LIST::Locate( wxDC* aDC, std::vector <WS_DRAW_ITEM_BASE*>& aList,
459  const wxPoint& aPosition )
460 {
461  for( WS_DRAW_ITEM_BASE* item = GetFirst(); item; item = GetNext() )
462  {
463  item->m_Flags &= ~(LOCATE_STARTPOINT|LOCATE_ENDPOINT);
464  bool found = false;
465 
466  if( item->HitTestStartPoint ( aDC, aPosition ) )
467  {
468  item->m_Flags |= LOCATE_STARTPOINT;
469  found = true;
470  }
471 
472  if( item->HitTestEndPoint ( aDC, aPosition ) )
473  {
474  item->m_Flags |= LOCATE_ENDPOINT;
475  found = true;
476  }
477 
478  if( found || item->HitTest( aPosition ) )
479  {
480  aList.push_back( item );
481  }
482  }
483 }
484 
485 
486 void WS_DRAW_ITEM_BITMAP::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
487  GR_DRAWMODE aDrawMode, COLOR4D aColor )
488 {
490 
491  if( parent->m_ImageBitmap )
492  {
493  GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ) ? GR_COPY : aDrawMode );
494  parent->m_ImageBitmap->DrawBitmap( aDC, m_pos + aOffset );
495  GRSetDrawMode( aDC, GR_COPY );
496  }
497 }
498 
499 
500 bool WS_DRAW_ITEM_BITMAP::HitTest( const wxPoint& aPosition) const
501 {
502  const WORKSHEET_DATAITEM_BITMAP* parent = static_cast<const WORKSHEET_DATAITEM_BITMAP*>( GetParent() );
503 
504  if( parent->m_ImageBitmap == NULL )
505  return false;
506 
507  EDA_RECT rect = parent->m_ImageBitmap->GetBoundingBox();
508  rect.Move( m_pos );
509  return rect.Contains( aPosition );
510 }
511 
512 
513 bool WS_DRAW_ITEM_BITMAP::HitTest( const EDA_RECT& aRect ) const
514 {
515  const WORKSHEET_DATAITEM_BITMAP* parent = static_cast<const WORKSHEET_DATAITEM_BITMAP*>( GetParent() );
516 
517  if( parent->m_ImageBitmap == NULL )
518  return false;
519 
520  EDA_RECT rect = parent->m_ImageBitmap->GetBoundingBox();
521  rect.Move( m_pos );
522  return rect.Intersects( aRect );
523 }
524 
525 
529 bool WS_DRAW_ITEM_BITMAP::HitTestStartPoint( wxDC *aDC, const wxPoint& aPosition )
530 {
531  wxPoint dist = m_pos - aPosition;
532  int marker_size = WORKSHEET_DATAITEM::GetMarkerSizeUi( getScaleFromZoom( aDC ) );
533 
534  if( std::abs( dist.x) <= marker_size / 2 &&
535  std::abs( dist.y) <= marker_size / 2 )
536  return true;
537 
538  return false;
539 }
540 
virtual void DrawWsItem(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
The function to draw a WS_DRAW_ITEM_POLYGON.
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, wxPoint Points[], bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:701
void Move(const wxPoint &aMoveVector)
Function Move moves the rectangle by the aMoveVector.
static const int dist[10][10]
Definition: ar_matrix.cpp:320
const wxPoint GetPosition() const
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:223
const wxPoint & GetTextPos() const
Definition: eda_text.h:237
bool Contains(const wxPoint &aPoint) const
Function Contains.
static double m_WSunits2Iu
WS_DRAW_ITEM_BASE * GetNext()
virtual bool HitTestStartPoint(wxDC *aDC, const wxPoint &aPosition) override
return true if the point aPosition is on the starting point of this item.
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 SetItalic(bool isItalic)
Definition: eda_text.h:182
int color
Definition: DXF_plotter.cpp:62
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:236
#define LOCATE_STARTPOINT
virtual void DrawWsItem(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
The function to draw a WS_DRAW_ITEM_LINE.
WS_DRAW_ITEM_BASE * GetFirst()
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:227
virtual bool HitTest(const wxPoint &aPosition) const override
Virtual function return true if the point aPosition is on the line.
virtual bool HitTest(const wxPoint &aPosition) const override
Virtual function return true if the point aPosition is inside one polygon.
virtual bool HitTest(const wxPoint &aPosition) const override
Virtual function return true if the point aPosition is on bitmap.
const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:778
#define abs(a)
Definition: auxiliary.h:84
#define LOCATE_ENDPOINT
Class EDA_TEXT is a mix-in class (via multiple inheritance) that handles texts such as labels...
Definition: eda_text.h:127
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1003
WS_DRAW_ITEM_TEXT(WORKSHEET_DATAITEM *aParent, wxString &aText, wxPoint aPos, wxSize aSize, int aPenWidth, COLOR4D aColor, bool aItalic=false, bool aBold=false)
bool TestPointInsidePolygon(const CPOLYGONS_LIST &aPolysList, int aIdxstart, int aIdxend, int aRefx, int aRefy)
Function TestPointInsidePolygon test if a point is inside or outside a polygon.
virtual void DrawWsItem(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
The function to draw a WS_DRAW_ITEM_BITMAP.
virtual bool TextHitTest(const wxPoint &aPoint, int aAccuracy=0) const
Function TextHitTest Test if aPoint is within the bounds of this object.
Definition: eda_text.cpp:255
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
WORKSHEET_DATAITEM * GetParent() const
description of graphic items and texts to build a title block
const wxPoint & GetEnd() const
COLOR4D GetColor() const
virtual bool HitTestStartPoint(wxDC *aDC, const wxPoint &aPosition) override
return true if the point aPosition is on the starting point of this item.
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:285
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
virtual bool HitTestStartPoint(wxDC *aDC, const wxPoint &aPosition) override
return true if the point aPosition is on the starting point of this item.
virtual bool HitTestStartPoint(wxDC *aDC, const wxPoint &aPosition) override
return true if the point aPosition is on the reference point of this item.
const int scale
Definition: colors.h:58
#define max(a, b)
Definition: auxiliary.h:86
virtual bool HitTestStartPoint(wxDC *aDC, const wxPoint &aPosition) override
return true if the point aPosition is on the starting point of this item.
virtual bool HitTestEndPoint(wxDC *aDC, const wxPoint &aPosition) override
return true if the point aPosition is on the ending point of this item This is avirtual function whic...
size_t i
Definition: json11.cpp:597
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
virtual bool HitTestEndPoint(wxDC *aDC, const wxPoint &aPosition) override
return true if the point aPosition is on the ending point of this item This is avirtual function whic...
void DrawBitmap(wxDC *aDC, const wxPoint &aPos)
virtual void DrawWsItem(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
The function to draw a WS_DRAW_ITEM_TEXT.
virtual bool HitTest(const wxPoint &aPosition) const override
Virtual function return true if the point aPosition is on the text.
void Locate(wxDC *aDC, std::vector< WS_DRAW_ITEM_BASE * > &aList, const wxPoint &aPosition)
Locate graphic items in m_graphicList at location aPosition.
classes and function to generate graphics to plt or draw titles blocks and frame references ...
virtual bool HitTest(const wxPoint &aPosition) const override
Virtual function return true if the point aPosition is on one edge of the rectangle.
virtual void DrawWsItem(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
The function to draw a WS_DRAW_ITEM_RECT.
void Draw(EDA_RECT *aClipBox, wxDC *aDC)
Draws the item list created by BuildWorkSheetGraphicList.
bool TestSegmentHit(const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
Function TestSegmentHit test for hit on line segment i.e.
Definition: trigo.cpp:122
void SetBold(bool aBold)
Definition: eda_text.h:185
const wxPoint GetPosition() const
void drawMarker(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aPos, int aSize, bool aEndPointShape=false)
static double getScaleFromZoom(wxDC *aDC)
void SetThickness(int aNewThickness)
Function SetThickness sets pen width.
Definition: eda_text.h:161
void Draw(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aDisplay_mode=FILLED, COLOR4D aAnchor_color=COLOR4D::UNSPECIFIED)
Function Draw.
Definition: eda_text.cpp:280
static int GetMarkerSizeUi(double aZoomScale=1.0)
#define min(a, b)
Definition: auxiliary.h:85
const wxPoint & GetStart() const
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39