2009-02-22 21:32:27 +00:00
|
|
|
|
/**********************
|
|
|
|
|
* class_base_screen.h
|
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
|
|
/* define :
|
|
|
|
|
* class BASE_SCREEN to handle how to draw a screen (a board, a schematic ...)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __CLASS_BASE_SCREEN_H__
|
|
|
|
|
#define __CLASS_BASE_SCREEN_H__
|
|
|
|
|
|
|
|
|
|
#include "base_struct.h"
|
2009-07-23 15:37:00 +00:00
|
|
|
|
#include "class_undoredo_container.h"
|
2009-07-25 04:53:39 +00:00
|
|
|
|
#include "block_commande.h"
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Forward declarations:
|
|
|
|
|
class SCH_ITEM;
|
|
|
|
|
class Ki_PageDescr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Simple class for handling grid arrays. */
|
|
|
|
|
class GRID_TYPE
|
|
|
|
|
{
|
|
|
|
|
public:
|
2009-07-25 04:53:39 +00:00
|
|
|
|
int m_Id;
|
2009-02-22 21:32:27 +00:00
|
|
|
|
wxRealPoint m_Size;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Declare array of wxSize for grid list implementation. */
|
|
|
|
|
#include <wx/dynarray.h>
|
|
|
|
|
WX_DECLARE_OBJARRAY( GRID_TYPE, GridArray );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************/
|
|
|
|
|
/* Class to handle how to draw a screen (a board, a schematic ...) */
|
|
|
|
|
/*******************************************************************/
|
|
|
|
|
class BASE_SCREEN : public EDA_BaseStruct
|
|
|
|
|
{
|
|
|
|
|
public:
|
2009-07-25 04:53:39 +00:00
|
|
|
|
wxPoint m_DrawOrg; /* offsets pour tracer le circuit sur l'ecran */
|
|
|
|
|
wxPoint m_Curseur; /* Screen cursor coordinate (on grid) in user units. */
|
|
|
|
|
wxPoint m_MousePosition; /* Mouse cursor coordinate (off grid) in user units. */
|
2009-04-05 20:49:15 +00:00
|
|
|
|
wxPoint m_MousePositionInPixels;
|
|
|
|
|
wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid) in user units.
|
|
|
|
|
* (coordinates from last reset position)*/
|
|
|
|
|
wxPoint m_ScrollbarPos; // Position effective des Curseurs de scroll
|
|
|
|
|
wxSize m_ScrollbarNumber; /* Valeur effective des Nombres de Scrool
|
|
|
|
|
* c.a.d taille en unites de scroll de la
|
|
|
|
|
* surface totale affichable */
|
|
|
|
|
wxPoint m_StartVisu; /* Coord absolues du 1er pixel visualis<69>a
|
|
|
|
|
* l'ecran (en nombre de pixels) */
|
|
|
|
|
|
|
|
|
|
wxSize m_SizeVisu; /* taille en pixels de l'ecran (fenetre de visu
|
|
|
|
|
* Utile pour recadrer les affichages lors de la
|
|
|
|
|
* navigation dans la hierarchie */
|
|
|
|
|
bool m_Center; /* fix the coordinate (0,0) position on
|
|
|
|
|
* screen : if TRUE (0,0) in centered on screen
|
|
|
|
|
* TRUE: when coordiantaes can be < 0 and
|
|
|
|
|
* > 0 all but schematic
|
|
|
|
|
* FALSE: when coordinates can be only >= 0
|
|
|
|
|
* Schematic */
|
2009-07-25 04:53:39 +00:00
|
|
|
|
bool m_FirstRedraw;
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
|
SCH_ITEM* EEDrawList; /* Object list (main data) for schematic */
|
2009-07-23 15:37:00 +00:00
|
|
|
|
|
|
|
|
|
// Undo/redo list of commands
|
2009-07-25 04:53:39 +00:00
|
|
|
|
UNDO_REDO_CONTAINER m_UndoList; /* Objects list for the undo command (old data) */
|
|
|
|
|
UNDO_REDO_CONTAINER m_RedoList; /* Objects list for the redo command (old data) */
|
|
|
|
|
unsigned m_UndoRedoCountMax; // undo/Redo command Max depth
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
|
|
|
|
/* block control */
|
2009-07-25 04:53:39 +00:00
|
|
|
|
BLOCK_SELECTOR m_BlockLocate; /* Block description for block commands */
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
|
|
|
|
/* Page description */
|
2009-07-25 04:53:39 +00:00
|
|
|
|
Ki_PageDescr* m_CurrentSheetDesc;
|
|
|
|
|
int m_ScreenNumber;
|
|
|
|
|
int m_NumberOfScreen;
|
|
|
|
|
|
|
|
|
|
wxString m_FileName;
|
|
|
|
|
wxString m_Title; /* titre de la feuille */
|
|
|
|
|
wxString m_Date; /* date de mise a jour */
|
|
|
|
|
wxString m_Revision; /* code de revision */
|
|
|
|
|
wxString m_Company; /* nom du proprietaire */
|
|
|
|
|
wxString m_Commentaire1;
|
|
|
|
|
wxString m_Commentaire2;
|
|
|
|
|
wxString m_Commentaire3;
|
|
|
|
|
wxString m_Commentaire4;
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
/* indicateurs divers */
|
|
|
|
|
char m_FlagRefreshReq; /* indique que l'ecran doit redessine */
|
|
|
|
|
char m_FlagModified; // indique modif du PCB,utilise pour eviter une sortie sans sauvegarde
|
|
|
|
|
char m_FlagSave; // indique sauvegarde auto faite
|
|
|
|
|
EDA_BaseStruct* m_CurrentItem; ///< Currently selected object
|
|
|
|
|
|
|
|
|
|
/* Valeurs du pas de grille et du zoom */
|
|
|
|
|
public:
|
2009-07-25 04:53:39 +00:00
|
|
|
|
wxRealPoint m_Grid; /* Current grid. */
|
|
|
|
|
GridArray m_GridList;
|
|
|
|
|
bool m_UserGridIsON;
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
|
wxArrayInt m_ZoomList; /* Array of standard zoom coefficients. */
|
|
|
|
|
int m_Zoom; /* Current zoom coefficient. */
|
|
|
|
|
int m_ZoomScalar; /* Allow zooming to non-integer increments. */
|
|
|
|
|
bool m_IsPrinting;
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
BASE_SCREEN( KICAD_T aType = SCREEN_STRUCT_TYPE );
|
|
|
|
|
~BASE_SCREEN();
|
|
|
|
|
|
|
|
|
|
BASE_SCREEN* Next() const { return (BASE_SCREEN*) Pnext; }
|
|
|
|
|
BASE_SCREEN* Back() const { return (BASE_SCREEN*) Pback; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function setCurItem
|
|
|
|
|
* sets the currently selected object, m_CurrentItem.
|
|
|
|
|
* @param current Any object derived from EDA_BaseStruct
|
|
|
|
|
*/
|
|
|
|
|
void SetCurItem( EDA_BaseStruct* current ) { m_CurrentItem = current; }
|
|
|
|
|
EDA_BaseStruct* GetCurItem() const { return m_CurrentItem; }
|
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
|
void InitDatas(); /* Inits completes des variables */
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
|
wxSize ReturnPageSize( void );
|
|
|
|
|
virtual int GetInternalUnits( void );
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
|
|
|
|
/** Function CursorRealPosition
|
|
|
|
|
* @return the position in user units of location ScreenPos
|
|
|
|
|
* @param ScreenPos = the screen (in pixel) position co convert
|
|
|
|
|
*/
|
2009-07-25 04:53:39 +00:00
|
|
|
|
wxPoint CursorRealPosition( const wxPoint& ScreenPos );
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
|
|
|
|
/* general Undo/Redo command control */
|
2009-07-29 13:10:36 +00:00
|
|
|
|
|
|
|
|
|
/** function ClearUndoORRedoList (virtual).
|
|
|
|
|
* this function must remove the aItemCount old commands from aList
|
|
|
|
|
* and delete commmands, pickers and picked items if needed
|
|
|
|
|
* Because picked items must be deleted only if they are not in use, this is a virtual pure
|
|
|
|
|
* function that must be created for SCH_SCREEN and PCB_SCREEN
|
|
|
|
|
* @param aList = the UNDO_REDO_CONTAINER of commands
|
|
|
|
|
* @param aItemCount = number of old commands to delete. -1 to remove all old commands
|
|
|
|
|
* this will empty the list of commands.
|
|
|
|
|
* Commands are deleted from the older to the last.
|
|
|
|
|
*/
|
|
|
|
|
virtual void ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount = -1) = 0;
|
|
|
|
|
|
|
|
|
|
/** Function ClearUndoRedoList
|
|
|
|
|
* clear undo and redo list, using ClearUndoORRedoList()
|
|
|
|
|
* picked items are deleted by ClearUndoORRedoList() according to their status
|
|
|
|
|
*/
|
2009-07-25 04:53:39 +00:00
|
|
|
|
virtual void ClearUndoRedoList();
|
2009-07-29 13:10:36 +00:00
|
|
|
|
|
|
|
|
|
/** function PushCommandToUndoList
|
|
|
|
|
* add a command to undo in undo list
|
|
|
|
|
* delete the very old commands when the max count of undo commands is reached
|
|
|
|
|
* ( using ClearUndoORRedoList)
|
|
|
|
|
*/
|
2009-07-25 04:53:39 +00:00
|
|
|
|
virtual void PushCommandToUndoList( PICKED_ITEMS_LIST* aItem );
|
2009-07-29 13:10:36 +00:00
|
|
|
|
|
|
|
|
|
/** function PushCommandToRedoList
|
|
|
|
|
* add a command to redo in redo list
|
|
|
|
|
* delete the very old commands when the max count of redo commands is reached
|
|
|
|
|
* ( using ClearUndoORRedoList)
|
|
|
|
|
*/
|
2009-07-25 04:53:39 +00:00
|
|
|
|
virtual void PushCommandToRedoList( PICKED_ITEMS_LIST* aItem );
|
2009-07-29 13:10:36 +00:00
|
|
|
|
|
|
|
|
|
/** PopCommandFromUndoList
|
|
|
|
|
* return the last command to undo and remove it from list
|
|
|
|
|
* nothing is deleted.
|
|
|
|
|
*/
|
2009-07-23 15:37:00 +00:00
|
|
|
|
virtual PICKED_ITEMS_LIST* PopCommandFromUndoList();
|
2009-07-29 13:10:36 +00:00
|
|
|
|
|
|
|
|
|
/** PopCommandFromRedoList
|
|
|
|
|
* return the last command to undo and remove it from list
|
|
|
|
|
* nothing is deleted.
|
|
|
|
|
*/
|
2009-07-23 15:37:00 +00:00
|
|
|
|
virtual PICKED_ITEMS_LIST* PopCommandFromRedoList();
|
2009-07-25 04:53:39 +00:00
|
|
|
|
|
|
|
|
|
int GetUndoCommandCount()
|
2009-07-23 15:37:00 +00:00
|
|
|
|
{
|
|
|
|
|
return m_UndoList.m_CommandsList.size();
|
|
|
|
|
}
|
2009-07-25 04:53:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int GetRedoCommandCount()
|
2009-07-23 15:37:00 +00:00
|
|
|
|
{
|
|
|
|
|
return m_RedoList.m_CommandsList.size();
|
|
|
|
|
}
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
|
|
2009-02-22 21:32:27 +00:00
|
|
|
|
/* Manipulation des flags */
|
|
|
|
|
void SetRefreshReq() { m_FlagRefreshReq = 1; }
|
|
|
|
|
void ClrRefreshReq() { m_FlagRefreshReq = 0; }
|
|
|
|
|
void SetModify() { m_FlagModified = 1; m_FlagSave = 0; }
|
|
|
|
|
void ClrModify() { m_FlagModified = 0; m_FlagSave = 1; }
|
|
|
|
|
void SetSave() { m_FlagSave = 1; }
|
|
|
|
|
void ClrSave() { m_FlagSave = 0; }
|
|
|
|
|
int IsModify() { return m_FlagModified & 1; }
|
|
|
|
|
int IsRefreshReq() { return m_FlagRefreshReq & 1; }
|
|
|
|
|
int IsSave() { return m_FlagSave & 1; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//----<zoom stuff>----------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/** Function GetScalingFactor
|
|
|
|
|
* @return the the current scale used to draw items on screen
|
|
|
|
|
* draw coordinates are user coordinates * GetScalingFactor( )
|
|
|
|
|
*/
|
|
|
|
|
double GetScalingFactor()
|
|
|
|
|
{
|
2009-04-08 18:06:22 +00:00
|
|
|
|
return (double) m_ZoomScalar / (double) GetZoom();
|
2009-02-22 21:32:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Function SetScalingFactor
|
|
|
|
|
* @param the the current scale used to draw items on screen
|
|
|
|
|
* draw coordinates are user coordinates * GetScalingFactor( )
|
|
|
|
|
*/
|
2009-07-25 04:53:39 +00:00
|
|
|
|
void SetScalingFactor( double aScale );
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
|
|
|
|
/** Function GetZoom
|
|
|
|
|
* @return the current zoom factor
|
|
|
|
|
* Note: the zoom factor is NOT the scaling factor
|
|
|
|
|
* the scaling factor is m_ZoomScalar * GetZoom()
|
|
|
|
|
*/
|
2009-07-25 04:53:39 +00:00
|
|
|
|
int GetZoom() const;
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function SetZoom
|
|
|
|
|
* adjusts the current zoom factor
|
|
|
|
|
*/
|
2009-07-25 04:53:39 +00:00
|
|
|
|
bool SetZoom( int coeff );
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function SetZoomList
|
|
|
|
|
* sets the list of zoom factors.
|
|
|
|
|
* @param aZoomList An array of zoom factors in ascending order, zero terminated
|
|
|
|
|
*/
|
2009-07-25 04:53:39 +00:00
|
|
|
|
void SetZoomList( const wxArrayInt& zoomlist );
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
|
int Scale( int coord );
|
|
|
|
|
double Scale( double coord );
|
|
|
|
|
void Scale( wxPoint& pt );
|
|
|
|
|
void Scale( wxSize& sz );
|
|
|
|
|
void Scale( wxRealPoint& sz );
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
|
int Unscale( int coord );
|
|
|
|
|
void Unscale( wxPoint& pt );
|
|
|
|
|
void Unscale( wxSize& sz );
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
|
bool SetNextZoom(); /* ajuste le prochain coeff de zoom */
|
|
|
|
|
bool SetPreviousZoom(); /* ajuste le precedent coeff de zoom */
|
|
|
|
|
bool SetFirstZoom(); /* ajuste le coeff de zoom a 1*/
|
|
|
|
|
bool SetLastZoom(); /* ajuste le coeff de zoom au max */
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
|
|
|
|
//----<grid stuff>----------------------------------------------------------
|
|
|
|
|
wxRealPoint GetGrid(); /* retourne la grille */
|
2009-07-25 04:53:39 +00:00
|
|
|
|
void SetGrid( const wxRealPoint& size );
|
|
|
|
|
void SetGrid( int );
|
|
|
|
|
void SetGridList( GridArray& sizelist );
|
|
|
|
|
void AddGrid( const GRID_TYPE& grid );
|
|
|
|
|
void AddGrid( const wxRealPoint& size, int id );
|
|
|
|
|
void AddGrid( const wxRealPoint& size, int units, int id );
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function RefPos
|
|
|
|
|
* returns the reference position, coming from either the mouse position or the
|
|
|
|
|
* the cursor position.
|
|
|
|
|
* @param useMouse If true, return mouse position, else cursor's.
|
|
|
|
|
* @return wxPoint - The reference point, either the mouse position or
|
|
|
|
|
* the cursor position.
|
|
|
|
|
*/
|
|
|
|
|
wxPoint RefPos( bool useMouse )
|
|
|
|
|
{
|
|
|
|
|
return useMouse ? m_MousePosition : m_Curseur;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function GetClass
|
|
|
|
|
* returns the class name.
|
|
|
|
|
* @return wxString
|
|
|
|
|
*/
|
|
|
|
|
virtual wxString GetClass() const
|
|
|
|
|
{
|
|
|
|
|
return wxT( "BASE_SCREEN" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function Show
|
|
|
|
|
* is used to output the object tree, currently for debugging only.
|
|
|
|
|
* @param nestLevel An aid to prettier tree indenting, and is the level
|
|
|
|
|
* of nesting of this object within the overall tree.
|
|
|
|
|
* @param os The ostream& to output to.
|
|
|
|
|
*/
|
|
|
|
|
void Show( int nestLevel, std::ostream& os );
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* #ifndef __CLASS_BASE_SCREEN_H__ */
|