KiCad PCB EDA Suite
block_commande.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
31 #ifndef __INCLUDE__BLOCK_COMMANDE_H__
32 #define __INCLUDE__BLOCK_COMMANDE_H__
33 
34 
35 #include <base_struct.h>
37 #include <gr_basic.h>
38 #include <class_eda_rect.h>
39 
40 /* Block state codes. */
41 typedef enum {
48 
49 
50 /* Block command codes. */
51 typedef enum {
61  BLOCK_DRAG_ITEM, // like BLOCK_DRAG, when used to drag a selected component
62  // and not using an area defined by a mouse drag
73 
74 
75 class BLOCK_SELECTOR : public EDA_RECT
76 {
77  BLOCK_STATE_T m_state; //< State (enum BLOCK_STATE_T) of the block.
78  BLOCK_COMMAND_T m_command; //< Command (enum BLOCK_COMMAND_T) operation.
79  PICKED_ITEMS_LIST m_items; //< List of items selected in this block.
80  COLOR4D m_color; //< Block Color (for drawings).
81  wxPoint m_moveVector; //< Move distance to move the block.
82  wxPoint m_lastCursorPosition; //< Last Mouse position in block command
83  //< last cursor position in move commands
84  //< 0,0 in paste command.
85 
86 public:
89 
90  void SetState( BLOCK_STATE_T aState ) { m_state = aState; }
91 
92  BLOCK_STATE_T GetState() const { return m_state; }
93 
94  void SetCommand( BLOCK_COMMAND_T aCommand ) { m_command = aCommand; }
95 
96  BLOCK_COMMAND_T GetCommand() const { return m_command; }
97 
98  void SetColor( COLOR4D aColor ) { m_color = aColor; }
99 
100  COLOR4D GetColor() const { return m_color; }
101 
108  void SetLastCursorPosition( const wxPoint& aPosition ) { m_lastCursorPosition = aPosition; }
109 
111 
112  void SetMoveVector( const wxPoint& aMoveVector ) { m_moveVector = aMoveVector; }
113 
114  wxPoint GetMoveVector() const { return m_moveVector; }
115 
121  void InitData( EDA_DRAW_PANEL* Panel, const wxPoint& startpos );
122 
127  void SetMessageBlock( EDA_DRAW_FRAME* frame );
128 
129  void Draw( EDA_DRAW_PANEL* aPanel,
130  wxDC* aDC,
131  const wxPoint& aOffset,
132  GR_DRAWMODE aDrawMode,
133  COLOR4D aColor );
134 
140  void PushItem( ITEM_PICKER& aItem );
141 
148 
154  void ClearItemsList();
155 
156  unsigned GetCount() const
157  {
158  return m_items.GetCount();
159  }
160 
162 
163  EDA_ITEM* GetItem( unsigned aIndex )
164  {
165  if( aIndex < m_items.GetCount() )
166  return m_items.GetPickedItem( aIndex );
167 
168  return NULL;
169  }
170 
175  bool IsDragging() const
176  {
177  return m_command == BLOCK_DRAG || m_command == BLOCK_DRAG_ITEM;
178  }
179 
184  inline bool IsIdle() const { return m_command == BLOCK_IDLE; }
185 
191  void Clear();
192 };
193 
194 
199 void AbortBlockCurrentCommand( EDA_DRAW_PANEL* aPanel, wxDC* aDC );
200 
201 
209 void DrawAndSizingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
210  bool aErase );
211 
212 
213 #endif /* __INCLUDE__BLOCK_COMMANDE_H__ */
BLOCK_COMMAND_T m_command
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor)
void SetMoveVector(const wxPoint &aMoveVector)
void AbortBlockCurrentCommand(EDA_DRAW_PANEL *aPanel, wxDC *aDC)
Function AbortBlockCurrentCommand cancels the current block operation.
void SetMessageBlock(EDA_DRAW_FRAME *frame)
Function SetMessageBlock Displays the type of block command in the status bar of the window...
BLOCK_COMMAND_T
EDA_ITEM * GetItem(unsigned aIndex)
BLOCK_STATE_T
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:54
void ClearItemsList()
Function ClearItemsList clear only the list of EDA_ITEM pointers, it does NOT delete the EDA_ITEM obj...
void SetState(BLOCK_STATE_T aState)
void ClearListAndDeleteItems()
Function ClearListAndDeleteItems deletes only the list of EDA_ITEM * pointers, AND the data printed b...
COLOR4D GetColor() const
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
void DrawAndSizingBlockOutlines(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function DrawAndSizingBlockOutlines redraws the outlines of the block which shows the search area for...
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
unsigned GetCount() const
Function GetCount.
PICKED_ITEMS_LIST m_items
bool IsIdle() const
Function IsIdle returns true if there is currently no block operation in progress.
wxPoint GetLastCursorPosition() const
BLOCK_STATE_T m_state
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
Function GetPickedItem.
BLOCK_STATE_T GetState() const
Class EDA_RECT handles the component boundary box.
wxPoint m_lastCursorPosition
void SetColor(COLOR4D aColor)
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
bool IsDragging() const
Function IsDragging returns true if the current block command is a drag operation.
PICKED_ITEMS_LIST & GetItems()
BLOCK_COMMAND_T GetCommand() const
wxPoint m_moveVector
void InitData(EDA_DRAW_PANEL *Panel, const wxPoint &startpos)
Function InitData sets the initial values of a BLOCK_SELECTOR, before starting a block command...
Basic classes for most KiCad items.
void SetLastCursorPosition(const wxPoint &aPosition)
Function SetLastCursorPosition sets the last cursor position to aPosition.
unsigned GetCount() const
void SetCommand(BLOCK_COMMAND_T aCommand)
wxPoint GetMoveVector() const
void Clear()
Function Clear clears the block selector by setting the command to idle, the state to no block...
void PushItem(ITEM_PICKER &aItem)
Function PushItem adds aItem to the list of items.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39