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>
|
2020-06-12 10:58:56 +00:00
|
|
|
* Copyright (C) 1992-2020 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
|
|
|
/**
|
2018-01-29 10:37:29 +00:00
|
|
|
* @file base_screen.h
|
2011-10-15 13:25:57 +00:00
|
|
|
* @brief BASE_SCREEN class implementation.
|
2009-02-22 21:32:27 +00:00
|
|
|
*/
|
|
|
|
|
2018-01-29 10:37:29 +00:00
|
|
|
#ifndef BASE_SCREEN_H
|
|
|
|
#define BASE_SCREEN_H
|
2009-02-22 21:32:27 +00:00
|
|
|
|
2019-06-08 22:14:57 +00:00
|
|
|
#include <eda_draw_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <base_struct.h>
|
2018-01-31 08:23:20 +00:00
|
|
|
#include <undo_redo_container.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <common.h>
|
2009-02-22 21:32:27 +00:00
|
|
|
|
|
|
|
|
2011-10-15 13:25:57 +00:00
|
|
|
/**
|
2020-01-10 14:31:00 +00:00
|
|
|
* 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
|
|
|
bool m_FlagModified; ///< Indicates current drawing has been modified.
|
|
|
|
bool m_FlagSave; ///< Indicates automatic file save.
|
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;
|
|
|
|
|
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
|
|
|
|
|
2019-06-13 13:34:38 +00:00
|
|
|
VECTOR2D m_LocalOrigin; ///< Relative Screen cursor coordinate (on grid)
|
2013-08-03 05:15:23 +00:00
|
|
|
///< in user units. (coordinates from last reset position)
|
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 */
|
2019-06-13 13:34:38 +00:00
|
|
|
|
|
|
|
VECTOR2D m_ScrollCenter; ///< Current scroll center point in logical units.
|
|
|
|
|
2018-09-16 21:19:33 +00:00
|
|
|
bool m_Initialized;
|
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
|
|
|
|
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
|
|
|
|
2009-02-22 21:32:27 +00:00
|
|
|
public:
|
2020-05-21 02:27:48 +00:00
|
|
|
BASE_SCREEN( EDA_ITEM* aParent, KICAD_T aType = SCREEN_T );
|
|
|
|
|
2020-06-13 21:09:02 +00:00
|
|
|
BASE_SCREEN( const wxSize& aPageSizeIU, KICAD_T aType = SCREEN_T ) :
|
|
|
|
BASE_SCREEN( nullptr, aType )
|
|
|
|
{
|
|
|
|
InitDataPoints( aPageSizeIU );
|
|
|
|
}
|
|
|
|
|
2020-05-21 02:27:48 +00:00
|
|
|
BASE_SCREEN( KICAD_T aType = SCREEN_T ) :
|
|
|
|
BASE_SCREEN( nullptr, aType )
|
|
|
|
{}
|
|
|
|
|
2019-06-13 13:34:38 +00:00
|
|
|
~BASE_SCREEN() override { }
|
2009-02-22 21:32:27 +00:00
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
void InitDataPoints( const wxSize& aPageSizeInternalUnits );
|
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.
|
|
|
|
*/
|
2020-06-13 21:09:02 +00:00
|
|
|
virtual void ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount = -1 )
|
|
|
|
{ }
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* 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" );
|
|
|
|
}
|
|
|
|
|
|
|
|
#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
|
|
|
|
};
|
|
|
|
|
2018-01-29 10:37:29 +00:00
|
|
|
#endif // BASE_SCREEN_H
|