KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
ds_proxy_undo_item.cpp
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) 2019 Kicad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
27#include <view/view.h>
28#include <eda_draw_frame.h>
29#include <string_utils.h>
30
31using namespace KIGFX;
32
35 m_selectedDataItem( INT_MAX ),
36 m_selectedDrawItem( INT_MAX )
37{
38 if( aFrame )
39 {
40 m_pageInfo = aFrame->GetPageSettings();
41 m_titleBlock = aFrame->GetTitleBlock();
42 }
43
46
47 for( size_t ii = 0; ii < model.GetItems().size(); ++ii )
48 {
49 DS_DATA_ITEM* dataItem = model.GetItem( ii );
50
51 for( size_t jj = 0; jj < dataItem->GetDrawItems().size(); ++jj )
52 {
53 DS_DRAW_ITEM_BASE* drawItem = dataItem->GetDrawItems()[ jj ];
54
55 if( drawItem->IsSelected() )
56 {
59 break;
60 }
61 }
62 }
63}
64
65
67{
69 {
70 aFrame->SetPageSettings( m_pageInfo );
71 aFrame->SetTitleBlock( m_titleBlock );
72 }
73
75
76 if( aView )
77 {
78 aView->Clear();
79
80 for( int ii = 0; ii < (int)DS_DATA_MODEL::GetTheInstance().GetItems().size(); ++ii )
81 {
83
84 dataItem->SyncDrawItems( nullptr, aView );
85
86 if( ii == m_selectedDataItem && m_selectedDrawItem < (int)dataItem->GetDrawItems().size() )
87 {
88 DS_DRAW_ITEM_BASE* drawItem = dataItem->GetDrawItems()[ m_selectedDrawItem ];
89 drawItem->SetSelected();
90 }
91 }
92 }
93}
94
Drawing sheet structure type definitions.
Definition: ds_data_item.h:96
virtual void SyncDrawItems(DS_DRAW_ITEM_LIST *aCollector, KIGFX::VIEW *aView)
const std::vector< DS_DRAW_ITEM_BASE * > & GetDrawItems() const
Definition: ds_data_item.h:110
Handle the graphic items list to draw/plot the frame and title block.
Definition: ds_data_model.h:39
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
DS_DATA_ITEM * GetItem(unsigned aIdx) const
void SaveInString(wxString *aOutputString)
Save the description in a buffer.
std::vector< DS_DATA_ITEM * > & GetItems()
void SetPageLayout(const char *aPageLayout, bool aAppend=false, const wxString &aSource=wxT("Sexpr_string"))
Populate the list from a S expr description stored in a string.
Base class to handle basic graphic items.
Definition: ds_draw_item.h:59
void Restore(EDA_DRAW_FRAME *aFrame, KIGFX::VIEW *aView=nullptr)
DS_PROXY_UNDO_ITEM(const EDA_DRAW_FRAME *aFrame)
The base class for create windows for drawing purpose.
virtual void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)=0
virtual const TITLE_BLOCK & GetTitleBlock() const =0
virtual const PAGE_INFO & GetPageSettings() const =0
virtual void SetPageSettings(const PAGE_INFO &aPageSettings)=0
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
bool IsSelected() const
Definition: eda_item.h:110
void SetSelected()
Definition: eda_item.h:119
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
void Clear()
Remove all items from the view.
Definition: view.cpp:1127
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: string_utils.h:398
@ WS_PROXY_UNDO_ITEM_T
Definition: typeinfo.h:223
@ WS_PROXY_UNDO_ITEM_PLUS_T
Definition: typeinfo.h:224