2012-03-26 23:47:08 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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-01-19 19:08:42 +00:00
|
|
|
/**
|
2009-11-23 20:18:47 +00:00
|
|
|
* This file is part of the common library.
|
2009-01-19 19:08:42 +00:00
|
|
|
* @file block_commande.h
|
|
|
|
* @see common.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __INCLUDE__BLOCK_COMMANDE_H__
|
2012-03-26 23:47:08 +00:00
|
|
|
#define __INCLUDE__BLOCK_COMMANDE_H__
|
2009-01-19 19:08:42 +00:00
|
|
|
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <base_struct.h>
|
|
|
|
#include <class_undoredo_container.h>
|
2012-09-01 13:38:27 +00:00
|
|
|
#include <gr_basic.h>
|
2009-01-19 19:08:42 +00:00
|
|
|
|
2009-11-23 20:18:47 +00:00
|
|
|
/* Block state codes. */
|
2009-07-25 04:53:39 +00:00
|
|
|
typedef enum {
|
2009-11-23 20:18:47 +00:00
|
|
|
STATE_NO_BLOCK,
|
|
|
|
STATE_BLOCK_INIT,
|
|
|
|
STATE_BLOCK_END,
|
|
|
|
STATE_BLOCK_MOVE,
|
|
|
|
STATE_BLOCK_STOP
|
2012-03-26 23:47:08 +00:00
|
|
|
} BLOCK_STATE_T;
|
2009-07-25 04:53:39 +00:00
|
|
|
|
2009-11-23 20:18:47 +00:00
|
|
|
|
|
|
|
/* Block command codes. */
|
2009-07-25 04:53:39 +00:00
|
|
|
typedef enum {
|
|
|
|
BLOCK_IDLE,
|
|
|
|
BLOCK_MOVE,
|
|
|
|
BLOCK_COPY,
|
|
|
|
BLOCK_SAVE,
|
|
|
|
BLOCK_DELETE,
|
|
|
|
BLOCK_PASTE,
|
|
|
|
BLOCK_DRAG,
|
|
|
|
BLOCK_ROTATE,
|
2009-08-12 10:40:01 +00:00
|
|
|
BLOCK_FLIP,
|
2009-07-25 04:53:39 +00:00
|
|
|
BLOCK_ZOOM,
|
|
|
|
BLOCK_ABORT,
|
|
|
|
BLOCK_PRESELECT_MOVE,
|
|
|
|
BLOCK_SELECT_ITEMS_ONLY,
|
|
|
|
BLOCK_MIRROR_X,
|
|
|
|
BLOCK_MIRROR_Y
|
2012-03-26 23:47:08 +00:00
|
|
|
} BLOCK_COMMAND_T;
|
2009-07-25 04:53:39 +00:00
|
|
|
|
|
|
|
|
2012-03-24 14:25:30 +00:00
|
|
|
class BLOCK_SELECTOR : public EDA_RECT
|
2009-07-25 04:53:39 +00:00
|
|
|
{
|
2012-03-26 23:47:08 +00:00
|
|
|
BLOCK_STATE_T m_state; //< State (enum BLOCK_STATE_T) of the block.
|
|
|
|
BLOCK_COMMAND_T m_command; //< Command (enum BLOCK_COMMAND_T) operation.
|
|
|
|
PICKED_ITEMS_LIST m_items; //< List of items selected in this block.
|
|
|
|
EDA_COLOR_T m_color; //< Block Color (for drawings).
|
|
|
|
wxPoint m_moveVector; //< Move distance to move the block.
|
|
|
|
wxPoint m_lastCursorPosition; //< Last Mouse position in block command
|
|
|
|
//< last cursor position in move commands
|
|
|
|
//< 0,0 in paste command.
|
2009-07-25 04:53:39 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
BLOCK_SELECTOR();
|
|
|
|
~BLOCK_SELECTOR();
|
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
void SetState( BLOCK_STATE_T aState ) { m_state = aState; }
|
|
|
|
|
|
|
|
BLOCK_STATE_T GetState() const { return m_state; }
|
|
|
|
|
|
|
|
void SetCommand( BLOCK_COMMAND_T aCommand ) { m_command = aCommand; }
|
|
|
|
|
|
|
|
BLOCK_COMMAND_T GetCommand() const { return m_command; }
|
|
|
|
|
|
|
|
void SetColor( EDA_COLOR_T aColor ) { m_color = aColor; }
|
|
|
|
|
|
|
|
EDA_COLOR_T GetColor() const { return m_color; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetLastCursorPosition
|
|
|
|
* sets the last cursor position to \a aPosition.
|
|
|
|
*
|
|
|
|
* @param aPosition The current cursor position.
|
|
|
|
*/
|
|
|
|
void SetLastCursorPosition( const wxPoint& aPosition ) { m_lastCursorPosition = aPosition; }
|
|
|
|
|
|
|
|
wxPoint GetLastCursorPosition() const { return m_lastCursorPosition; }
|
|
|
|
|
|
|
|
void SetMoveVector( const wxPoint& aMoveVector ) { m_moveVector = aMoveVector; }
|
|
|
|
|
|
|
|
wxPoint GetMoveVector() const { return m_moveVector; }
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function InitData
|
2010-11-12 17:33:20 +00:00
|
|
|
* sets the initial values of a BLOCK_SELECTOR, before starting a block
|
|
|
|
* command
|
2009-07-25 04:53:39 +00:00
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
void InitData( EDA_DRAW_PANEL* Panel, const wxPoint& startpos );
|
2009-11-23 20:18:47 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function SetMessageBlock
|
2009-07-25 04:53:39 +00:00
|
|
|
* Displays the type of block command in the status bar of the window
|
2009-11-23 20:18:47 +00:00
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
void SetMessageBlock( EDA_DRAW_FRAME* frame );
|
2009-07-25 04:53:39 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void Draw( EDA_DRAW_PANEL* aPanel,
|
2012-03-26 23:47:08 +00:00
|
|
|
wxDC* aDC,
|
|
|
|
const wxPoint& aOffset,
|
2012-09-01 13:38:27 +00:00
|
|
|
GR_DRAWMODE aDrawMode,
|
2012-09-02 12:06:47 +00:00
|
|
|
EDA_COLOR_T aColor );
|
2009-07-25 04:53:39 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function PushItem
|
2012-03-26 23:47:08 +00:00
|
|
|
* adds \a aItem to the list of items.
|
2009-07-25 04:53:39 +00:00
|
|
|
* @param aItem = an ITEM_PICKER to add to the list
|
|
|
|
*/
|
2009-11-23 20:18:47 +00:00
|
|
|
void PushItem( ITEM_PICKER& aItem );
|
2009-07-25 04:53:39 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function ClearListAndDeleteItems
|
2010-12-08 20:12:46 +00:00
|
|
|
* deletes only the list of EDA_ITEM * pointers, AND the data printed
|
2009-11-23 20:18:47 +00:00
|
|
|
* by m_Item
|
2009-07-25 04:53:39 +00:00
|
|
|
*/
|
2009-11-23 20:18:47 +00:00
|
|
|
void ClearListAndDeleteItems();
|
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
/**
|
|
|
|
* Function ClearItemsList
|
|
|
|
* clear only the list of #EDA_ITEM pointers, it does _NOT_ delete the #EDA_ITEM object
|
|
|
|
* itself
|
|
|
|
*/
|
2009-11-23 20:18:47 +00:00
|
|
|
void ClearItemsList();
|
2009-07-25 04:53:39 +00:00
|
|
|
|
2012-09-02 12:06:47 +00:00
|
|
|
unsigned GetCount() const
|
2009-07-25 04:53:39 +00:00
|
|
|
{
|
2012-03-26 23:47:08 +00:00
|
|
|
return m_items.GetCount();
|
2009-07-25 04:53:39 +00:00
|
|
|
}
|
2010-11-11 21:46:55 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
PICKED_ITEMS_LIST& GetItems() { return m_items; }
|
|
|
|
|
|
|
|
EDA_ITEM* GetItem( unsigned aIndex )
|
2010-11-11 21:46:55 +00:00
|
|
|
{
|
2012-03-26 23:47:08 +00:00
|
|
|
if( aIndex < m_items.GetCount() )
|
|
|
|
return m_items.GetPickedItem( aIndex );
|
|
|
|
|
|
|
|
return NULL;
|
2010-11-11 21:46:55 +00:00
|
|
|
}
|
2011-01-07 19:24:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function IsDragging
|
|
|
|
* returns true if the current block command is a drag operation.
|
|
|
|
*/
|
2012-03-26 23:47:08 +00:00
|
|
|
bool IsDragging() const { return m_command == BLOCK_DRAG; }
|
2011-02-05 19:22:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function IsIdle
|
|
|
|
* returns true if there is currently no block operation in progress.
|
|
|
|
*/
|
2012-03-26 23:47:08 +00:00
|
|
|
inline bool IsIdle() const { return m_command == BLOCK_IDLE; }
|
2011-02-05 19:22:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Clear
|
|
|
|
* clears the block selector by setting the command to idle, the state to no block,
|
|
|
|
* and clears the selected item list.
|
|
|
|
*/
|
|
|
|
void Clear();
|
2009-07-25 04:53:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
/**
|
|
|
|
* Function AbortBlockCurrentCommand
|
|
|
|
* cancels the current block operation.
|
2009-11-23 20:18:47 +00:00
|
|
|
*/
|
2012-03-26 23:47:08 +00:00
|
|
|
void AbortBlockCurrentCommand( EDA_DRAW_PANEL* aPanel, wxDC* aDC );
|
2009-07-25 04:53:39 +00:00
|
|
|
|
2009-01-19 19:08:42 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
/**
|
|
|
|
* Function DrawAndSizingBlockOutlines
|
|
|
|
* redraws the outlines of the block which shows the search area for block commands.
|
|
|
|
*
|
|
|
|
* The first point of the rectangle showing the area is initialized by InitBlockLocateDatas().
|
|
|
|
* The other point of the rectangle is the mouse cursor position.
|
2009-07-25 04:53:39 +00:00
|
|
|
*/
|
2011-02-03 19:27:28 +00:00
|
|
|
void DrawAndSizingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
|
|
|
bool aErase );
|
2009-01-19 19:08:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* __INCLUDE__BLOCK_COMMANDE_H__ */
|