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 {
60  BLOCK_DRAG_ITEM, // like BLOCK_DRAG, when used to drag a selected component
61  // and not using an area defined by a mouse drag
72 
73 
74 class BLOCK_SELECTOR : public EDA_RECT
75 {
76  BLOCK_STATE_T m_state; //< State (enum BLOCK_STATE_T) of the block.
77  BLOCK_COMMAND_T m_command; //< Command (enum BLOCK_COMMAND_T) operation.
78  PICKED_ITEMS_LIST m_items; //< List of items selected in this block.
79  COLOR4D m_color; //< Block Color (for drawings).
80  wxPoint m_moveVector; //< Move distance to move the block.
81  wxPoint m_lastCursorPosition; //< Last Mouse position in block command
82  //< last cursor position in move commands
83  //< 0,0 in paste command.
84 
85 public:
88 
89  void SetState( BLOCK_STATE_T aState ) { m_state = aState; }
90 
91  BLOCK_STATE_T GetState() const { return m_state; }
92 
93  void SetCommand( BLOCK_COMMAND_T aCommand ) { m_command = aCommand; }
94 
95  BLOCK_COMMAND_T GetCommand() const { return m_command; }
96 
97  void SetColor( COLOR4D aColor ) { m_color = aColor; }
98 
99  COLOR4D GetColor() const { return m_color; }
100 
107  void SetLastCursorPosition( const wxPoint& aPosition ) { m_lastCursorPosition = aPosition; }
108 
110 
111  void SetMoveVector( const wxPoint& aMoveVector ) { m_moveVector = aMoveVector; }
112 
113  wxPoint GetMoveVector() const { return m_moveVector; }
114 
120  void InitData( EDA_DRAW_PANEL* Panel, const wxPoint& startpos );
121 
126  void SetMessageBlock( EDA_DRAW_FRAME* frame );
127 
128  void Draw( EDA_DRAW_PANEL* aPanel,
129  wxDC* aDC,
130  const wxPoint& aOffset,
131  GR_DRAWMODE aDrawMode,
132  COLOR4D aColor );
133 
139  void PushItem( ITEM_PICKER& aItem );
140 
147 
153  void ClearItemsList();
154 
155  unsigned GetCount() const
156  {
157  return m_items.GetCount();
158  }
159 
161 
162  EDA_ITEM* GetItem( unsigned aIndex )
163  {
164  if( aIndex < m_items.GetCount() )
165  return m_items.GetPickedItem( aIndex );
166 
167  return NULL;
168  }
169 
174  bool IsDragging() const
175  {
176  return m_command == BLOCK_DRAG || m_command == BLOCK_DRAG_ITEM;
177  }
178 
183  inline bool IsIdle() const { return m_command == BLOCK_IDLE; }
184 
190  void Clear();
191 };
192 
193 
198 void AbortBlockCurrentCommand( EDA_DRAW_PANEL* aPanel, wxDC* aDC );
199 
200 
208 void DrawAndSizingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
209  bool aErase );
210 
211 
212 #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:53
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:151
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