2018-08-03 12:18:26 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2017 CERN
|
|
|
|
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <view/view.h>
|
|
|
|
#include <view/view_group.h>
|
2018-10-10 15:26:23 +00:00
|
|
|
#include <view/view_rtree.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <view/wx_view_controls.h>
|
|
|
|
#include <worksheet_viewitem.h>
|
|
|
|
#include <layers_id_colors_and_visibility.h>
|
|
|
|
#include <class_libentry.h>
|
|
|
|
#include <sch_sheet.h>
|
|
|
|
#include <sch_screen.h>
|
|
|
|
#include <preview_items/selection_area.h>
|
|
|
|
|
2018-09-16 21:19:33 +00:00
|
|
|
#include "sch_view.h"
|
2018-08-03 12:18:26 +00:00
|
|
|
|
|
|
|
|
2018-09-16 21:19:33 +00:00
|
|
|
namespace KIGFX {
|
2018-08-03 12:18:26 +00:00
|
|
|
|
|
|
|
|
2018-09-16 21:19:33 +00:00
|
|
|
SCH_VIEW::SCH_VIEW( bool aIsDynamic ) :
|
|
|
|
VIEW( aIsDynamic )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-16 21:19:33 +00:00
|
|
|
SCH_VIEW::~SCH_VIEW()
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-16 08:36:10 +00:00
|
|
|
void SCH_VIEW::DisplaySheet( SCH_SCREEN *aScreen )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
|
|
|
|
2018-11-16 08:36:10 +00:00
|
|
|
for( auto item = aScreen->GetDrawItems(); item; item = item->Next() )
|
2018-09-04 20:53:04 +00:00
|
|
|
Add( item );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-11-16 08:36:10 +00:00
|
|
|
m_worksheet.reset( new KIGFX::WORKSHEET_VIEWITEM( 1, &aScreen->GetPageSettings(),
|
|
|
|
&aScreen->GetTitleBlock() ) );
|
|
|
|
m_worksheet->SetSheetNumber( aScreen->m_ScreenNumber );
|
|
|
|
m_worksheet->SetSheetCount( aScreen->m_NumberOfScreens );
|
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
m_selectionArea.reset( new KIGFX::PREVIEW::SELECTION_AREA( ) );
|
|
|
|
m_preview.reset( new KIGFX::VIEW_GROUP () );
|
2018-09-16 21:19:33 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
Add( m_worksheet.get() );
|
|
|
|
Add( m_selectionArea.get() );
|
|
|
|
Add( m_preview.get() );
|
|
|
|
}
|
|
|
|
|
2018-09-16 21:19:33 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
void SCH_VIEW::DisplaySheet( SCH_SHEET *aSheet )
|
|
|
|
{
|
|
|
|
DisplaySheet( aSheet->GetScreen() );
|
|
|
|
}
|
|
|
|
|
2018-09-16 21:19:33 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
void SCH_VIEW::DisplayComponent( LIB_PART *aPart )
|
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
|
2018-10-11 13:31:17 +00:00
|
|
|
if( !aPart )
|
|
|
|
return;
|
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
for ( auto &item : aPart->GetDrawItems() )
|
2018-10-23 15:02:55 +00:00
|
|
|
Add( &item );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
|
|
|
m_selectionArea.reset( new KIGFX::PREVIEW::SELECTION_AREA( ) );
|
|
|
|
m_preview.reset( new KIGFX::VIEW_GROUP () );
|
|
|
|
Add( m_selectionArea.get() );
|
|
|
|
Add( m_preview.get() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_VIEW::ClearPreview()
|
|
|
|
{
|
|
|
|
m_preview->Clear();
|
2018-09-16 21:19:33 +00:00
|
|
|
|
2018-10-18 09:50:43 +00:00
|
|
|
for( auto item : m_ownedItems )
|
2018-08-03 12:18:26 +00:00
|
|
|
delete item;
|
|
|
|
|
2018-10-18 09:50:43 +00:00
|
|
|
m_ownedItems.clear();
|
|
|
|
Update( m_preview.get() );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-09-16 21:19:33 +00:00
|
|
|
|
2018-10-18 09:50:43 +00:00
|
|
|
void SCH_VIEW::AddToPreview( EDA_ITEM *aItem, bool takeOwnership )
|
2018-08-03 12:18:26 +00:00
|
|
|
{
|
2018-10-18 09:50:43 +00:00
|
|
|
Hide( aItem, false );
|
2018-09-10 10:58:50 +00:00
|
|
|
m_preview->Add( aItem );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2018-10-18 09:50:43 +00:00
|
|
|
if( takeOwnership )
|
|
|
|
m_ownedItems.push_back( aItem );
|
2018-09-10 10:58:50 +00:00
|
|
|
|
|
|
|
SetVisible( m_preview.get(), true );
|
|
|
|
Hide( m_preview.get(), false );
|
|
|
|
Update( m_preview.get() );
|
2018-08-03 12:18:26 +00:00
|
|
|
}
|
|
|
|
|
2018-09-16 21:19:33 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
void SCH_VIEW::ShowSelectionArea( bool aShow )
|
|
|
|
{
|
2018-09-05 22:17:22 +00:00
|
|
|
if( aShow )
|
|
|
|
{
|
|
|
|
// Reset seleciton area so the previous one doesn't flash before the first
|
|
|
|
// mouse move updates it
|
|
|
|
m_selectionArea->SetOrigin( VECTOR2I() );
|
|
|
|
m_selectionArea->SetEnd( VECTOR2I() );
|
|
|
|
}
|
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
SetVisible( m_selectionArea.get(), aShow );
|
|
|
|
}
|
|
|
|
|
2018-09-16 21:19:33 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
void SCH_VIEW::ShowPreview( bool aShow )
|
|
|
|
{
|
|
|
|
SetVisible( m_preview.get(), aShow );
|
|
|
|
}
|
|
|
|
|
2018-09-16 21:19:33 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
void SCH_VIEW::ClearHiddenFlags()
|
|
|
|
{
|
2018-07-05 06:35:50 +00:00
|
|
|
for( auto item : *m_allItems )
|
2018-08-03 12:18:26 +00:00
|
|
|
Hide ( item, false );
|
|
|
|
}
|
|
|
|
|
2018-09-16 21:19:33 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
void SCH_VIEW::HideWorksheet()
|
|
|
|
{
|
|
|
|
// SetVisible( m_worksheet.get(), false );
|
|
|
|
}
|
|
|
|
|
2018-09-16 21:19:33 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
};
|
|
|
|
|