2009-02-02 12:12:18 +00:00
|
|
|
/******************************
|
|
|
|
* drawpanel.h:
|
2011-01-21 19:30:59 +00:00
|
|
|
* define class EDA_DRAW_PANEL
|
2009-02-02 12:12:18 +00:00
|
|
|
*************************************/
|
|
|
|
|
|
|
|
#ifndef PANEL_WXSTRUCT_H
|
|
|
|
#define PANEL_WXSTRUCT_H
|
|
|
|
|
|
|
|
#include "colors.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "base_struct.h"
|
2010-09-21 23:46:02 +00:00
|
|
|
#include <wx/overlay.h>
|
2009-02-02 12:12:18 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
class EDA_DRAW_FRAME;
|
2009-02-02 12:12:18 +00:00
|
|
|
class BASE_SCREEN;
|
2009-02-04 15:25:03 +00:00
|
|
|
class PCB_SCREEN;
|
2009-02-02 12:12:18 +00:00
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
class EDA_DRAW_PANEL : public wxScrolledWindow
|
2009-02-02 12:12:18 +00:00
|
|
|
{
|
2009-12-21 12:05:36 +00:00
|
|
|
private:
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_DRAW_FRAME* m_Parent;
|
2009-12-21 12:05:36 +00:00
|
|
|
|
|
|
|
public:
|
2009-11-23 20:18:47 +00:00
|
|
|
EDA_Rect m_ClipBox; // the clipbox used in screen
|
|
|
|
// redraw (usually gives the
|
|
|
|
// visible area in internal units)
|
|
|
|
wxPoint m_CursorStartPos; // useful in testing the cursor
|
|
|
|
// movement
|
|
|
|
|
2010-02-08 18:15:42 +00:00
|
|
|
int m_scrollIncrementX; // X axis scroll increment in pixels per unit.
|
|
|
|
int m_scrollIncrementY; // Y axis scroll increment in pixels per unit.
|
2009-11-23 20:18:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool m_AbortRequest; // Flag to abort long commands
|
|
|
|
bool m_AbortEnable; // TRUE if abort button or menu to
|
|
|
|
// be displayed
|
2009-02-02 12:12:18 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
bool m_DisableEraseBG; // if true: do not allow background erasure
|
|
|
|
// (used to reduce flicker in Gerbview )
|
|
|
|
|
2009-02-02 12:12:18 +00:00
|
|
|
|
|
|
|
bool m_AutoPAN_Enable; // TRUE to allow auto pan
|
2009-11-23 20:18:47 +00:00
|
|
|
bool m_AutoPAN_Request; // TRUE to request an auto pan
|
|
|
|
// (will be made only if
|
|
|
|
// m_AutoPAN_Enable = true)
|
2009-02-02 12:12:18 +00:00
|
|
|
|
2009-11-23 20:18:47 +00:00
|
|
|
int m_IgnoreMouseEvents; // when non-zero (true), then
|
|
|
|
// ignore mouse events
|
2009-02-02 12:12:18 +00:00
|
|
|
|
|
|
|
bool m_Block_Enable; // TRUE to accept Block Commands
|
2010-07-27 16:49:38 +00:00
|
|
|
// useful to avoid false start block in certain cases
|
|
|
|
// (like switch from a sheet to an other sheet
|
2009-11-23 20:18:47 +00:00
|
|
|
int m_CanStartBlock; // >= 0 (or >= n) if a block can
|
|
|
|
// start
|
|
|
|
bool m_PrintIsMirrored; // True when drawing in mirror
|
|
|
|
// mode. Used in draw arc function,
|
|
|
|
// because arcs are oriented, and
|
|
|
|
// in mirror mode, orientations are
|
|
|
|
// reversed
|
|
|
|
int m_PanelDefaultCursor; // Current mouse cursor default
|
|
|
|
// shape id for this window
|
|
|
|
int m_PanelCursor; // Current mouse cursor shape id
|
|
|
|
// for this window
|
|
|
|
int m_CursorLevel; // Index for cursor redraw in XOR
|
|
|
|
// mode
|
|
|
|
|
2010-10-09 08:08:29 +00:00
|
|
|
#ifdef USE_WX_OVERLAY
|
2010-09-21 23:46:02 +00:00
|
|
|
// MAC Uses overlay to workaround the wxINVERT and wxXOR miss
|
2010-11-12 15:17:10 +00:00
|
|
|
wxOverlay m_overlay;
|
2010-09-21 23:46:02 +00:00
|
|
|
#endif
|
2009-02-02 12:12:18 +00:00
|
|
|
/* Cursor management (used in editing functions) */
|
2009-11-23 20:18:47 +00:00
|
|
|
|
|
|
|
/* Mouse capture move callback function prototype. */
|
2011-01-21 19:30:59 +00:00
|
|
|
void (*ManageCurseur)( EDA_DRAW_PANEL* panel, wxDC* DC, bool erase );
|
2009-11-23 20:18:47 +00:00
|
|
|
|
|
|
|
/* Abort managed cursor callback function prototype. */
|
2011-01-21 19:30:59 +00:00
|
|
|
void (*ForceCloseManageCurseur)( EDA_DRAW_PANEL* panel, wxDC* DC );
|
2009-02-02 12:12:18 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id, const wxPoint& pos, const wxSize& size );
|
|
|
|
~EDA_DRAW_PANEL();
|
2009-02-02 12:12:18 +00:00
|
|
|
|
|
|
|
BASE_SCREEN* GetScreen();
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_DRAW_FRAME* GetParent()
|
2009-12-21 12:05:36 +00:00
|
|
|
{
|
|
|
|
return m_Parent;
|
|
|
|
}
|
2009-02-02 12:12:18 +00:00
|
|
|
|
|
|
|
void OnPaint( wxPaintEvent& event );
|
|
|
|
void OnSize( wxSizeEvent& event );
|
2010-01-17 14:20:29 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function DrawBackGround
|
2010-01-17 14:20:29 +00:00
|
|
|
* @param DC = current Device Context
|
|
|
|
* Draws (if allowed) :
|
|
|
|
* the grid
|
|
|
|
* X and Y axis
|
|
|
|
* X and Y auxiliary axis
|
|
|
|
*/
|
2009-02-02 12:12:18 +00:00
|
|
|
void DrawBackGround( wxDC* DC );
|
2010-01-17 14:20:29 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function DrawGrid
|
2010-01-17 14:20:29 +00:00
|
|
|
* @param DC = current Device Context
|
|
|
|
* draws the grid
|
|
|
|
* - the grid is drawn only if the zoom level allows a good visibility
|
|
|
|
* - the grid is always centered on the screen center
|
|
|
|
*/
|
|
|
|
void DrawGrid( wxDC* DC );
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function DrawAuxiliaryAxis
|
2010-01-17 14:20:29 +00:00
|
|
|
* Draw the Auxiliary Axis, used in pcbnew which as origin coordinates
|
|
|
|
* for gerber and excellon files
|
2010-12-28 11:24:42 +00:00
|
|
|
* @param aDC = current Device Context
|
|
|
|
* @param aDrawMode = draw mode (GR_COPY, GR_OR ..)
|
2010-01-17 14:20:29 +00:00
|
|
|
*/
|
2010-12-28 11:24:42 +00:00
|
|
|
void DrawAuxiliaryAxis( wxDC* aDC, int aDrawMode );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function DrawGridAxis
|
|
|
|
* Draw on auxiliary axis, used in pcbnew to show grid origin, when
|
|
|
|
* the grid origin is set by user, and is not (0,0)
|
|
|
|
* @param aDC = current Device Context
|
|
|
|
* @param aDrawMode = draw mode (GR_COPY, GR_OR ..)
|
|
|
|
*/
|
|
|
|
void DrawGridAxis( wxDC* aDC, int aDrawMode );
|
|
|
|
|
2010-07-13 10:42:32 +00:00
|
|
|
void OnEraseBackground( wxEraseEvent& event );
|
2010-01-17 14:20:29 +00:00
|
|
|
|
2009-02-02 12:12:18 +00:00
|
|
|
void OnActivate( wxActivateEvent& event );
|
|
|
|
|
2010-02-08 18:15:42 +00:00
|
|
|
/**
|
|
|
|
* Prepare the device context for drawing.
|
|
|
|
*
|
|
|
|
* This overrides wxScrolledWindow::DoPrepareDC() for drawing depending
|
|
|
|
* on the render mode selected a build time. If the old kicad coordinate
|
|
|
|
* scaling code is used then this code doesn't do any thing other than
|
|
|
|
* update the boundary box. If wxDC coordinate manipulation is used, then
|
|
|
|
* the scale factor and drawing logical offset is set. Then the base
|
|
|
|
* method is called to set the DC device origin and user scale. This
|
|
|
|
* connects everything together to acheive the appropiate coordinate
|
|
|
|
* manipulation using wxDC LogicalToDeviceXXX and DeviceToLogixalXXX
|
|
|
|
* methods. This gets called automatically for a paint event. If you do
|
|
|
|
* any drawing outside the paint event, you must call DoPrepareDC manually.
|
|
|
|
*
|
|
|
|
* @param dc - The device context to prepare.
|
|
|
|
*/
|
|
|
|
virtual void DoPrepareDC(wxDC& dc);
|
|
|
|
|
2009-02-02 12:12:18 +00:00
|
|
|
/* Mouse and keys events */
|
|
|
|
void OnMouseWheel( wxMouseEvent& event );
|
|
|
|
void OnMouseEvent( wxMouseEvent& event );
|
|
|
|
void OnMouseLeaving( wxMouseEvent& event );
|
|
|
|
void OnKeyEvent( wxKeyEvent& event );
|
|
|
|
|
|
|
|
void OnPan( wxCommandEvent& event );
|
|
|
|
|
|
|
|
void EraseScreen( wxDC* DC );
|
|
|
|
void OnScrollWin( wxCommandEvent& event );
|
|
|
|
void OnScroll( wxScrollWinEvent& event );
|
|
|
|
|
|
|
|
void SetZoom( int mode );
|
|
|
|
int GetZoom();
|
2009-02-07 08:33:25 +00:00
|
|
|
void SetGrid( const wxRealPoint& size );
|
|
|
|
wxRealPoint GetGrid();
|
2009-02-02 12:12:18 +00:00
|
|
|
|
|
|
|
bool OnRightClick( wxMouseEvent& event );
|
|
|
|
void Process_Special_Functions( wxCommandEvent& event );
|
|
|
|
|
2009-12-21 12:05:36 +00:00
|
|
|
bool IsPointOnDisplay( wxPoint ref_pos );
|
2010-02-08 18:15:42 +00:00
|
|
|
void SetBoundaryBox( wxDC* dc );
|
2009-12-21 12:05:36 +00:00
|
|
|
void ReDraw( wxDC* DC, bool erasebg = TRUE );
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function CursorRealPosition
|
2009-02-02 12:12:18 +00:00
|
|
|
* @return the position in user units of location ScreenPos
|
2010-12-29 17:47:32 +00:00
|
|
|
* @param aPosition = the screen (in pixel) position to convert
|
2009-02-02 12:12:18 +00:00
|
|
|
*/
|
2010-12-29 17:47:32 +00:00
|
|
|
wxPoint CursorRealPosition( const wxPoint& aPosition );
|
2009-02-02 12:12:18 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function CursorScreenPosition
|
2009-02-02 12:12:18 +00:00
|
|
|
* @return the curseur current position in pixels in the screen draw area
|
|
|
|
*/
|
|
|
|
wxPoint CursorScreenPosition();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function PostDirtyRect
|
|
|
|
* appends the given rectangle in pcb units to the DrawPanel's invalid
|
|
|
|
* region list so that very soon (but not immediately), this rectangle
|
|
|
|
* along with any other recently posted rectangles is redrawn. Conversion
|
|
|
|
* to pixels is done in here.
|
|
|
|
* @param aRect The rectangle to append, it must be orthogonal
|
2009-11-23 20:18:47 +00:00
|
|
|
* (vertical and horizontal edges only), and it must be [,) in nature,
|
|
|
|
* i.e. [pos, dim) == [inclusive, exclusive)
|
2009-02-02 12:12:18 +00:00
|
|
|
*/
|
|
|
|
void PostDirtyRect( EDA_Rect aRect );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function ConvertPcbUnitsToPixelsUnits
|
|
|
|
* converts pos and size of the given EDA_Rect to pos and size in pixels,
|
|
|
|
* relative to the current draw area (origin 0,0 is the left top visible
|
|
|
|
* corner of draw area) according to the current scroll and zoom.
|
|
|
|
* @param aRect = the rectangle to convert
|
|
|
|
*/
|
|
|
|
void ConvertPcbUnitsToPixelsUnits( EDA_Rect* aRect );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function ConvertPcbUnitsToPixelsUnits
|
2009-11-23 20:18:47 +00:00
|
|
|
* converts a given wxPoint position (in internal units) to units of
|
|
|
|
* pixels, relative to the current draw area (origin 0,0 is the left
|
|
|
|
* top visible
|
2009-02-02 12:12:18 +00:00
|
|
|
* corner of draw area) according to the current scroll and zoom.
|
|
|
|
* @param aPosition = the position to convert
|
|
|
|
*/
|
|
|
|
void ConvertPcbUnitsToPixelsUnits( wxPoint* aPosition );
|
|
|
|
|
|
|
|
wxPoint GetScreenCenterRealPosition( void );
|
|
|
|
void MouseToCursorSchema();
|
|
|
|
void MouseTo( const wxPoint& Mouse );
|
|
|
|
|
|
|
|
/* Cursor functions */
|
2010-01-22 18:13:43 +00:00
|
|
|
/**
|
|
|
|
* Draw the user cursor.
|
|
|
|
*
|
|
|
|
* The user cursor is not the mouse cursor although they may be at the
|
|
|
|
* same screen position. The mouse cursor is still render by the OS.
|
|
|
|
* This is a drawn cursor that is used to snap to grid when grid snapping
|
|
|
|
* is enabled. This is required because OSX does not allow moving the
|
|
|
|
* cursor programmatically.
|
|
|
|
*
|
|
|
|
* @param aDC - the device context to draw the cursor
|
|
|
|
* @param aColor - the color to draw the cursor
|
|
|
|
*/
|
|
|
|
void DrawCursor( wxDC* aDC, int aColor = WHITE );
|
|
|
|
|
2009-12-21 12:05:36 +00:00
|
|
|
// remove the grid cursor from the display
|
|
|
|
void CursorOff( wxDC* DC );
|
|
|
|
// display the grid cursor
|
|
|
|
void CursorOn( wxDC* DC );
|
2009-02-02 12:12:18 +00:00
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
/**
|
|
|
|
* Release managed cursor.
|
|
|
|
*
|
|
|
|
* Check to see if the cursor is being managed for block or editing
|
|
|
|
* commands and release it.
|
|
|
|
*/
|
2009-09-18 14:56:05 +00:00
|
|
|
void UnManageCursor( int id = -1, int cursor = -1,
|
|
|
|
const wxString& title = wxEmptyString );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2009-02-02 12:12:18 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* #ifndef PANEL_WXSTRUCT_H */
|