2011-10-15 13:25:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-05-12 09:05:36 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
2011-10-15 13:25:57 +00:00
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
2015-05-12 09:05:36 +00:00
|
|
|
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-15 13:25:57 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
2009-02-22 21:32:27 +00:00
|
|
|
|
2011-10-15 13:25:57 +00:00
|
|
|
/**
|
|
|
|
* @file class_base_screen.h
|
|
|
|
* @brief BASE_SCREEN class implementation.
|
2009-02-22 21:32:27 +00:00
|
|
|
*/
|
|
|
|
|
2011-12-14 17:25:42 +00:00
|
|
|
#ifndef CLASS_BASE_SCREEN_H_
|
|
|
|
#define CLASS_BASE_SCREEN_H_
|
2009-02-22 21:32:27 +00:00
|
|
|
|
2015-08-06 00:10:52 +00:00
|
|
|
#include <draw_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <base_struct.h>
|
|
|
|
#include <class_undoredo_container.h>
|
|
|
|
#include <block_commande.h>
|
|
|
|
#include <common.h>
|
2015-05-12 09:05:36 +00:00
|
|
|
#include <id.h>
|
2009-02-22 21:32:27 +00:00
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
/**
|
|
|
|
* Class GRID_TYPE
|
|
|
|
* is for grid arrays.
|
|
|
|
*/
|
2009-02-22 21:32:27 +00:00
|
|
|
class GRID_TYPE
|
|
|
|
{
|
|
|
|
public:
|
2015-05-12 09:05:36 +00:00
|
|
|
int m_CmdId; // The command id of this grid ( first id is ID_POPUP_GRID_LEVEL_1000 )
|
|
|
|
wxRealPoint m_Size; // the size in internal unit of the grid (can differ for X and Y axis)
|
2009-10-14 19:43:31 +00:00
|
|
|
|
|
|
|
GRID_TYPE& operator=( const GRID_TYPE& item )
|
|
|
|
{
|
|
|
|
if( this != &item )
|
|
|
|
{
|
2015-05-12 09:05:36 +00:00
|
|
|
m_CmdId = item.m_CmdId;
|
2009-10-14 19:43:31 +00:00
|
|
|
m_Size = item.m_Size;
|
|
|
|
}
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
const bool operator==( const GRID_TYPE& item ) const
|
|
|
|
{
|
2015-05-12 09:05:36 +00:00
|
|
|
return m_Size == item.m_Size && m_CmdId == item.m_CmdId;
|
2009-10-14 19:43:31 +00:00
|
|
|
}
|
2009-02-22 21:32:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-03-21 17:00:11 +00:00
|
|
|
typedef std::vector<GRID_TYPE> GRIDS;
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
|
|
|
2011-10-15 13:25:57 +00:00
|
|
|
/**
|
|
|
|
* Class BASE_SCREEN
|
2011-12-22 21:57:50 +00:00
|
|
|
* handles how to draw a screen (a board, a schematic ...)
|
2011-10-15 13:25:57 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
class BASE_SCREEN : public EDA_ITEM
|
2009-02-22 21:32:27 +00:00
|
|
|
{
|
2012-05-27 00:19:12 +00:00
|
|
|
private:
|
2013-08-03 05:15:23 +00:00
|
|
|
GRIDS m_grids; ///< List of valid grid sizes.
|
|
|
|
bool m_FlagModified; ///< Indicates current drawing has been modified.
|
|
|
|
bool m_FlagSave; ///< Indicates automatic file save.
|
|
|
|
EDA_ITEM* m_CurrentItem; ///< Currently selected object
|
|
|
|
GRID_TYPE m_Grid; ///< Current grid selection.
|
|
|
|
wxPoint m_scrollCenter; ///< Current scroll center point in logical units.
|
|
|
|
wxPoint m_MousePosition; ///< Mouse cursor coordinate in logical units.
|
2015-08-05 14:28:27 +00:00
|
|
|
int m_UndoRedoCountMax; ///< undo/Redo command Max depth
|
2011-02-11 20:48:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The cross hair position in logical (drawing) units. The cross hair is not the cursor
|
|
|
|
* position. It is an addition indicator typically drawn on grid to indicate to the
|
|
|
|
* user where the current action will be performed.
|
|
|
|
*/
|
2013-08-03 05:15:23 +00:00
|
|
|
wxPoint m_crossHairPosition;
|
|
|
|
|
|
|
|
double m_Zoom; ///< Current zoom coefficient.
|
|
|
|
|
|
|
|
//----< Old public API now is private, and migratory>------------------------
|
|
|
|
// called only from EDA_DRAW_FRAME
|
|
|
|
friend class EDA_DRAW_FRAME;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function getCrossHairPosition
|
|
|
|
* return the current cross hair position in logical (drawing) coordinates.
|
|
|
|
* @param aInvertY Inverts the Y axis position.
|
|
|
|
* @return The cross hair position in drawing coordinates.
|
|
|
|
*/
|
2013-08-03 20:20:55 +00:00
|
|
|
wxPoint getCrossHairPosition( bool aInvertY ) const
|
2013-08-03 05:15:23 +00:00
|
|
|
{
|
|
|
|
if( aInvertY )
|
|
|
|
return wxPoint( m_crossHairPosition.x, -m_crossHairPosition.y );
|
2010-11-03 14:13:15 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
return wxPoint( m_crossHairPosition.x, m_crossHairPosition.y );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function setCrossHairPosition
|
|
|
|
* sets the screen cross hair position to \a aPosition in logical (drawing) units.
|
|
|
|
* @param aPosition The new cross hair position.
|
|
|
|
* @param aGridOrigin Origin point of the snap grid.
|
|
|
|
* @param aSnapToGrid Sets the cross hair position to the nearest grid position to
|
|
|
|
* \a aPosition.
|
|
|
|
*
|
|
|
|
*/
|
2013-08-03 20:20:55 +00:00
|
|
|
void setCrossHairPosition( const wxPoint& aPosition, const wxPoint& aGridOrigin, bool aSnapToGrid );
|
2013-08-03 05:15:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function getCursorScreenPosition
|
|
|
|
* returns the cross hair position in device (display) units.b
|
|
|
|
* @return The current cross hair position.
|
|
|
|
*/
|
|
|
|
wxPoint getCrossHairScreenPosition() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function getNearestGridPosition
|
|
|
|
* returns the nearest \a aGridSize location to \a aPosition.
|
|
|
|
* @param aPosition The position to check.
|
|
|
|
* @param aGridOrigin The origin point of the snap grid.
|
|
|
|
* @param aGridSize The grid size to locate to if provided. If NULL then the current
|
|
|
|
* grid size is used.
|
|
|
|
* @return The nearst grid position.
|
|
|
|
*/
|
|
|
|
wxPoint getNearestGridPosition( const wxPoint& aPosition, const wxPoint& aGridOrigin,
|
2013-08-03 20:20:55 +00:00
|
|
|
wxRealPoint* aGridSize ) const;
|
2013-08-03 05:15:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function getCursorPosition
|
|
|
|
* returns the current cursor position in logical (drawing) units.
|
|
|
|
* @param aOnGrid Returns the nearest grid position at the current cursor position.
|
|
|
|
* @param aGridOrigin Origin point of the snap grid.
|
|
|
|
* @param aGridSize Custom grid size instead of the current grid size. Only valid
|
|
|
|
* if \a aOnGrid is true.
|
|
|
|
* @return The current cursor position.
|
|
|
|
*/
|
2013-08-03 20:20:55 +00:00
|
|
|
wxPoint getCursorPosition( bool aOnGrid, const wxPoint& aGridOrigin, wxRealPoint* aGridSize ) const;
|
2013-08-03 05:15:23 +00:00
|
|
|
|
|
|
|
void setMousePosition( const wxPoint& aPosition ) { m_MousePosition = aPosition; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function RefPos
|
|
|
|
* Return the reference position, coming from either the mouse position
|
|
|
|
* or 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 ) const
|
|
|
|
{
|
|
|
|
return useMouse ? m_MousePosition : m_crossHairPosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
const wxPoint& getScrollCenterPosition() const { return m_scrollCenter; }
|
|
|
|
void setScrollCenterPosition( const wxPoint& aPoint ) { m_scrollCenter = aPoint; }
|
|
|
|
|
|
|
|
//----</Old public API now is private, and migratory>------------------------
|
2011-12-31 05:44:00 +00:00
|
|
|
|
|
|
|
|
2009-02-22 21:32:27 +00:00
|
|
|
public:
|
2013-07-19 18:27:22 +00:00
|
|
|
static wxString m_PageLayoutDescrFileName; ///< the name of the page layout descr file,
|
|
|
|
///< or emty to used the default pagelayout
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
wxPoint m_DrawOrg; ///< offsets for drawing the circuit on the screen
|
|
|
|
|
|
|
|
wxPoint m_O_Curseur; ///< Relative Screen cursor coordinate (on grid)
|
|
|
|
///< in user units. (coordinates from last reset position)
|
2011-02-02 19:01:21 +00:00
|
|
|
|
2010-02-14 18:14:33 +00:00
|
|
|
// Scrollbars management:
|
2013-08-03 05:15:23 +00:00
|
|
|
int m_ScrollPixelsPerUnitX; ///< Pixels per scroll unit in the horizontal direction.
|
|
|
|
int m_ScrollPixelsPerUnitY; ///< Pixels per scroll unit in the vertical direction.
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
wxSize m_ScrollbarNumber; /**< Current virtual draw area size in scroll units.
|
2011-02-02 19:01:21 +00:00
|
|
|
* m_ScrollbarNumber * m_ScrollPixelsPerUnit =
|
|
|
|
* virtual draw area size in pixels */
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
wxPoint m_ScrollbarPos; ///< Current scroll bar position in scroll units.
|
2011-02-02 19:01:21 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
wxPoint m_StartVisu; /**< Coordinates in drawing units of the current
|
|
|
|
* view position (upper left corner of device)
|
|
|
|
*/
|
2011-02-02 19:01:21 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
bool m_Center; /**< Center on screen. If true (0.0) is centered
|
|
|
|
* on screen coordinates can be < 0 and
|
|
|
|
* > 0 except for schematics.
|
|
|
|
* false: when coordinates can only be >= 0
|
|
|
|
* Schematic */
|
|
|
|
bool m_FirstRedraw;
|
2009-02-22 21:32:27 +00:00
|
|
|
|
2009-07-23 15:37:00 +00:00
|
|
|
// Undo/redo list of commands
|
2012-05-09 00:26:15 +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)
|
2009-02-22 21:32:27 +00:00
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
// block control
|
2012-05-09 00:26:15 +00:00
|
|
|
BLOCK_SELECTOR m_BlockLocate; ///< Block description for block commands
|
2009-02-22 21:32:27 +00:00
|
|
|
|
2012-05-06 20:10:43 +00:00
|
|
|
int m_ScreenNumber;
|
2012-05-27 00:19:12 +00:00
|
|
|
int m_NumberOfScreens;
|
2009-11-23 20:18:47 +00:00
|
|
|
|
2015-05-01 09:31:23 +00:00
|
|
|
std::vector<double> m_ZoomList; ///< standard zoom (i.e. scale) coefficients.
|
2012-05-06 20:10:43 +00:00
|
|
|
bool m_IsPrinting;
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
|
|
public:
|
2011-10-01 19:24:27 +00:00
|
|
|
BASE_SCREEN( KICAD_T aType = SCREEN_T );
|
2009-02-22 21:32:27 +00:00
|
|
|
~BASE_SCREEN();
|
|
|
|
|
|
|
|
/**
|
2011-09-20 13:57:40 +00:00
|
|
|
* Function SetCurItem
|
2009-02-22 21:32:27 +00:00
|
|
|
* sets the currently selected object, m_CurrentItem.
|
2011-03-03 19:55:44 +00:00
|
|
|
* @param aItem Any object derived from EDA_ITEM
|
2010-12-08 20:12:46 +00:00
|
|
|
*/
|
2011-03-03 19:55:44 +00:00
|
|
|
void SetCurItem( EDA_ITEM* aItem ) { m_CurrentItem = aItem; }
|
2011-09-20 13:57:40 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* GetCurItem() const { return m_CurrentItem; }
|
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
void InitDataPoints( const wxSize& aPageSizeInternalUnits );
|
2009-02-22 21:32:27 +00:00
|
|
|
|
2011-11-07 19:04:24 +00:00
|
|
|
/**
|
2012-04-16 23:31:29 +00:00
|
|
|
* Function MilsToIuScalar
|
|
|
|
* returns the scalar required to convert mils to internal units.
|
2011-11-07 19:04:24 +00:00
|
|
|
*
|
2012-04-16 23:31:29 +00:00
|
|
|
* @note This is a temporary hack until the derived objects SCH_SCREEN and PCB_SCREEN
|
|
|
|
* no longer need to be derived from BASE_SCREEN. I does allow removal of the
|
|
|
|
* obsolete GetInternalUnits function.
|
2011-11-07 19:04:24 +00:00
|
|
|
*/
|
2012-04-16 23:31:29 +00:00
|
|
|
virtual int MilsToIuScalar() { return 1; }
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
|
|
/* general Undo/Redo command control */
|
2009-07-29 13:10:36 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function ClearUndoORRedoList (virtual).
|
2009-07-29 13:10:36 +00:00
|
|
|
* this function must remove the aItemCount old commands from aList
|
2009-10-14 19:43:31 +00:00
|
|
|
* and delete commands, pickers and picked items if needed
|
2009-11-23 20:18:47 +00:00
|
|
|
* 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
|
2009-07-29 13:10:36 +00:00
|
|
|
* @param aList = the UNDO_REDO_CONTAINER of commands
|
2009-11-23 20:18:47 +00:00
|
|
|
* @param aItemCount = number of old commands to delete. -1 to remove all
|
|
|
|
* old commands this will empty the list of commands.
|
2009-07-29 13:10:36 +00:00
|
|
|
* Commands are deleted from the older to the last.
|
|
|
|
*/
|
2010-10-20 20:24:26 +00:00
|
|
|
virtual void ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount = -1 ) = 0;
|
2009-07-29 13:10:36 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function ClearUndoRedoList
|
2009-07-29 13:10:36 +00:00
|
|
|
* clear undo and redo list, using ClearUndoORRedoList()
|
2009-11-23 20:18:47 +00:00
|
|
|
* picked items are deleted by ClearUndoORRedoList() according to their
|
|
|
|
* status
|
2009-07-29 13:10:36 +00:00
|
|
|
*/
|
2011-11-07 19:04:24 +00:00
|
|
|
virtual void ClearUndoRedoList();
|
2009-07-29 13:10:36 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function PushCommandToUndoList
|
2009-07-29 13:10:36 +00:00
|
|
|
* add a command to undo in undo list
|
2009-11-23 20:18:47 +00:00
|
|
|
* delete the very old commands when the max count of undo commands is
|
|
|
|
* reached
|
2009-07-29 13:10:36 +00:00
|
|
|
* ( using ClearUndoORRedoList)
|
|
|
|
*/
|
2011-11-07 19:04:24 +00:00
|
|
|
virtual void PushCommandToUndoList( PICKED_ITEMS_LIST* aItem );
|
2009-07-29 13:10:36 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function PushCommandToRedoList
|
2009-07-29 13:10:36 +00:00
|
|
|
* add a command to redo in redo list
|
2009-11-23 20:18:47 +00:00
|
|
|
* delete the very old commands when the max count of redo commands is
|
|
|
|
* reached
|
2009-07-29 13:10:36 +00:00
|
|
|
* ( using ClearUndoORRedoList)
|
|
|
|
*/
|
2011-11-07 19:04:24 +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
|
|
|
|
2012-05-27 00:19:12 +00:00
|
|
|
int GetUndoCommandCount() const
|
2009-07-23 15:37:00 +00:00
|
|
|
{
|
|
|
|
return m_UndoList.m_CommandsList.size();
|
|
|
|
}
|
2009-07-25 04:53:39 +00:00
|
|
|
|
2012-05-27 00:19:12 +00:00
|
|
|
int GetRedoCommandCount() const
|
2009-07-23 15:37:00 +00:00
|
|
|
{
|
|
|
|
return m_RedoList.m_CommandsList.size();
|
|
|
|
}
|
2009-02-22 21:32:27 +00:00
|
|
|
|
2015-08-05 14:28:27 +00:00
|
|
|
int GetMaxUndoItems() const { return m_UndoRedoCountMax; }
|
|
|
|
|
|
|
|
void SetMaxUndoItems( int aMax )
|
|
|
|
{
|
|
|
|
if( aMax >= 0 && aMax < ABS_MAX_UNDO_ITEMS )
|
|
|
|
m_UndoRedoCountMax = aMax;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxFAIL_MSG( "Maximum undo items not within limits" );
|
|
|
|
m_UndoRedoCountMax = DEFAULT_MAX_UNDO_ITEMS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
void SetModify() { m_FlagModified = true; }
|
|
|
|
void ClrModify() { m_FlagModified = false; }
|
|
|
|
void SetSave() { m_FlagSave = true; }
|
|
|
|
void ClrSave() { m_FlagSave = false; }
|
|
|
|
bool IsModify() const { return m_FlagModified; }
|
|
|
|
bool IsSave() const { return m_FlagSave; }
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
|
|
|
2009-11-23 20:18:47 +00:00
|
|
|
//----<zoom stuff>---------------------------------------------------------
|
2009-02-22 21:32:27 +00:00
|
|
|
|
2012-05-06 20:10:43 +00:00
|
|
|
/**
|
|
|
|
* Function GetZoom
|
|
|
|
* returns the current "zoom factor", which is a measure of
|
|
|
|
* "internal units per device unit", or "world units per device unit".
|
|
|
|
* A device unit is typically a pixel.
|
|
|
|
*/
|
|
|
|
double GetZoom() const { return m_Zoom; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetZoom
|
|
|
|
* adjusts the current zoom factor.
|
|
|
|
*
|
|
|
|
* @param iu_per_du is the number of internal units (world units) per
|
|
|
|
* device units (pixels typically).
|
|
|
|
*/
|
|
|
|
bool SetZoom( double iu_per_du );
|
|
|
|
|
|
|
|
bool SetNextZoom();
|
|
|
|
bool SetPreviousZoom();
|
|
|
|
bool SetFirstZoom();
|
|
|
|
bool SetLastZoom();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetMaxAllowedZoom
|
|
|
|
* returns the maximum allowed zoom factor, which was established as the last entry
|
|
|
|
* in m_ZoomList.
|
|
|
|
*/
|
|
|
|
double GetMaxAllowedZoom() const { return m_ZoomList.size() ? *m_ZoomList.rbegin() : 1.0; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetMinAllowedZoom
|
|
|
|
* returns the minimum allowed zoom factor, which was established as the first entry
|
|
|
|
* in m_ZoomList.
|
|
|
|
*/
|
|
|
|
double GetMinAllowedZoom() const { return m_ZoomList.size() ? *m_ZoomList.begin() : 1.0; }
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function SetScalingFactor
|
2012-05-09 00:26:15 +00:00
|
|
|
* sets the scaling factor of "internal unit per device unit".
|
2012-04-23 21:56:26 +00:00
|
|
|
* If the output device is a screen, then "device units" are pixels. The
|
|
|
|
* "logical unit" is wx terminology, and corresponds to KiCad's "Internal Unit (IU)".
|
2012-05-09 00:26:15 +00:00
|
|
|
* <p>
|
|
|
|
* This scaling factor is "internal units per device unit". This function is
|
|
|
|
* the same thing currently as SetZoom(), but clamps the argument within a
|
|
|
|
* legal range.
|
2012-04-23 21:56:26 +00:00
|
|
|
|
2012-05-09 00:26:15 +00:00
|
|
|
* @param iu_per_du is the current scale used to draw items onto the device
|
|
|
|
* context wxDC.
|
2009-02-22 21:32:27 +00:00
|
|
|
*/
|
2012-05-09 00:26:15 +00:00
|
|
|
void SetScalingFactor( double iu_per_du );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetScalingFactor
|
|
|
|
* returns the inverse of the current scale used to draw items on screen.
|
|
|
|
* <p>
|
|
|
|
* This function somehow got designed to be the inverse of SetScalingFactor().
|
|
|
|
* <p>
|
|
|
|
* device coordinates = user coordinates * GetScalingFactor()
|
|
|
|
*/
|
|
|
|
double GetScalingFactor() const;
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
//----<grid stuff>----------------------------------------------------------
|
2009-10-14 19:43:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the command ID of the currently selected grid.
|
|
|
|
*
|
|
|
|
* @return int - Currently selected grid command ID.
|
|
|
|
*/
|
2015-05-12 09:05:36 +00:00
|
|
|
int GetGridCmdId() const { return m_Grid.m_CmdId; }
|
2009-10-14 19:43:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the grid size of the currently selected grid.
|
|
|
|
*
|
|
|
|
* @return wxRealPoint - The currently selected grid size.
|
|
|
|
*/
|
2012-05-27 00:19:12 +00:00
|
|
|
const wxRealPoint& GetGridSize() const { return m_Grid.m_Size; }
|
2009-10-14 19:43:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the grid object of the currently selected grid.
|
|
|
|
*
|
|
|
|
* @return GRID_TYPE - The currently selected grid.
|
|
|
|
*/
|
2012-05-27 00:19:12 +00:00
|
|
|
const GRID_TYPE& GetGrid() const { return m_Grid; }
|
|
|
|
|
2014-02-02 19:51:50 +00:00
|
|
|
/**
|
|
|
|
* set the current grid size m_Grid.
|
|
|
|
* The size must be existing in grid list (in m_grids)
|
|
|
|
* If not, the near existing grid size is used
|
|
|
|
* @param size = the size of the new grid
|
|
|
|
* @return the grid id offset (id from ID_POPUP_GRID_LEVEL_1000 )
|
|
|
|
* of the currently selected grid.
|
|
|
|
*/
|
|
|
|
int SetGrid( const wxRealPoint& size );
|
2011-11-07 19:04:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetGrid
|
2014-02-02 19:51:50 +00:00
|
|
|
* sets the grid size from command ID (not an index in grid list, but a wxID).
|
|
|
|
* @param aCommandId = the wxWidgets command ID
|
|
|
|
* @return the grid id offset (id from ID_POPUP_GRID_LEVEL_1000 )
|
|
|
|
* of the currently selected grid.
|
2011-11-07 19:04:24 +00:00
|
|
|
*/
|
2014-02-02 19:51:50 +00:00
|
|
|
int SetGrid( int aCommandId );
|
|
|
|
|
2011-11-07 19:04:24 +00:00
|
|
|
void SetGridList( GRIDS& sizelist );
|
|
|
|
void AddGrid( const GRID_TYPE& grid );
|
|
|
|
void AddGrid( const wxRealPoint& size, int id );
|
|
|
|
void AddGrid( const wxRealPoint& size, EDA_UNITS_T aUnit, int id );
|
2009-02-22 21:32:27 +00:00
|
|
|
|
2015-05-12 09:05:36 +00:00
|
|
|
/**
|
|
|
|
* Function GridExists
|
|
|
|
* tests for grid command ID (not an index in grid list, but a wxID) exists in grid list.
|
|
|
|
* @param aCommandId = the wxWidgets command ID
|
|
|
|
* @return true if the grid exists in grid list.
|
|
|
|
*/
|
|
|
|
bool GridExists( int aCommandId );
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
/**
|
|
|
|
* Function GetGridCount().
|
|
|
|
* Return the size of the grid list.
|
|
|
|
*
|
|
|
|
* @returns - The size of the grid list.
|
|
|
|
*/
|
2011-11-07 19:04:24 +00:00
|
|
|
size_t GetGridCount() const { return m_grids.size(); }
|
2010-12-08 20:12:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetGrid()
|
|
|
|
* Returns the grid object at \a aIndex.
|
|
|
|
*
|
|
|
|
* @param aIndex - The grid list index.
|
|
|
|
* @return - The grid object at \a aIndex or the current grid if the grid list is empty.
|
|
|
|
*/
|
2011-11-07 19:04:24 +00:00
|
|
|
GRID_TYPE& GetGrid( size_t aIndex );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetGrids().
|
2014-03-21 17:00:11 +00:00
|
|
|
* Returns the current list of grids.
|
2010-12-08 20:12:46 +00:00
|
|
|
*/
|
2014-03-21 17:00:11 +00:00
|
|
|
const GRIDS& GetGrids() const
|
|
|
|
{
|
|
|
|
return m_grids;
|
|
|
|
}
|
2009-02-22 21:32:27 +00:00
|
|
|
|
2015-01-05 13:20:04 +00:00
|
|
|
/**
|
|
|
|
* Function BuildGridsChoiceList().
|
|
|
|
* Build the human readable list of grid list, for menus or combo boxes
|
|
|
|
* the list shows the grid size both in mils or mm.
|
|
|
|
* @param aGridsList = a wxArrayString to populate
|
|
|
|
* @param aMmFirst = true to have mm first and mils after
|
|
|
|
* false to have mils first and mm after
|
|
|
|
* @return the index of the curr grid in list, if found or -1
|
|
|
|
*/
|
|
|
|
int BuildGridsChoiceList( wxArrayString& aGridsList, bool aMmFirst) const;
|
|
|
|
|
|
|
|
|
2009-02-22 21:32:27 +00:00
|
|
|
/**
|
|
|
|
* Function GetClass
|
|
|
|
* returns the class name.
|
|
|
|
* @return wxString
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual wxString GetClass() const override
|
2009-02-22 21:32:27 +00:00
|
|
|
{
|
|
|
|
return wxT( "BASE_SCREEN" );
|
|
|
|
}
|
|
|
|
|
2011-02-05 19:22:58 +00:00
|
|
|
inline bool IsBlockActive() const { return !m_BlockLocate.IsIdle(); }
|
|
|
|
|
|
|
|
void ClearBlockCommand() { m_BlockLocate.Clear(); }
|
|
|
|
|
2009-02-22 21:32:27 +00:00
|
|
|
#if defined(DEBUG)
|
2016-09-24 18:53:15 +00:00
|
|
|
void Show( int nestLevel, std::ostream& os ) const override;
|
2009-02-22 21:32:27 +00:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2011-12-14 17:25:42 +00:00
|
|
|
#endif // CLASS_BASE_SCREEN_H_
|