2023-10-06 17:04:00 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2023 Alex Shvartzkop <dudesuchamazing@gmail.com>
|
|
|
|
* Copyright (C) 2023 KiCad Developers, see AUTHORS.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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GENERATOR_H_
|
|
|
|
#define GENERATOR_H_
|
|
|
|
|
|
|
|
|
|
|
|
#include <unordered_set>
|
|
|
|
#include <string_any_map.h>
|
|
|
|
|
|
|
|
#include <pcb_group.h>
|
|
|
|
|
|
|
|
class EDIT_POINTS;
|
|
|
|
class BOARD;
|
|
|
|
class BOARD_ITEM;
|
|
|
|
class PCB_BASE_EDIT_FRAME;
|
|
|
|
class GENERATOR_TOOL;
|
2023-10-17 12:03:38 +00:00
|
|
|
class STATUS_MIN_MAX_POPUP;
|
2023-10-06 17:04:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
class PCB_GENERATOR : public PCB_GROUP
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
PCB_GENERATOR( BOARD_ITEM* aParent, PCB_LAYER_ID aLayer );
|
|
|
|
|
|
|
|
virtual ~PCB_GENERATOR();
|
|
|
|
|
2023-12-16 16:11:45 +00:00
|
|
|
virtual void EditStart( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit );
|
2023-10-06 17:04:00 +00:00
|
|
|
|
2023-12-16 16:11:45 +00:00
|
|
|
virtual void EditPush( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit,
|
|
|
|
const wxString& aCommitMsg = wxEmptyString, int aCommitFlags = 0 );
|
2023-10-06 17:04:00 +00:00
|
|
|
|
2023-12-16 16:11:45 +00:00
|
|
|
virtual void EditRevert( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit );
|
2023-10-06 17:04:00 +00:00
|
|
|
|
2023-12-16 16:11:45 +00:00
|
|
|
virtual void Remove( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit );
|
2023-10-06 17:04:00 +00:00
|
|
|
|
2023-12-16 16:11:45 +00:00
|
|
|
virtual bool Update( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit );
|
2023-10-06 17:04:00 +00:00
|
|
|
|
2023-12-06 13:08:05 +00:00
|
|
|
#define STATUS_ITEMS_ONLY true
|
|
|
|
|
2023-12-02 10:32:45 +00:00
|
|
|
virtual std::vector<EDA_ITEM*> GetPreviewItems( GENERATOR_TOOL* aTool,
|
|
|
|
PCB_BASE_EDIT_FRAME* aFrame,
|
2023-12-06 13:08:05 +00:00
|
|
|
bool aStatusItemsOnly = false );
|
2023-12-02 10:32:45 +00:00
|
|
|
|
2023-10-06 17:04:00 +00:00
|
|
|
virtual bool MakeEditPoints( std::shared_ptr<EDIT_POINTS> aEditPoints ) const;
|
|
|
|
|
|
|
|
virtual bool UpdateFromEditPoints( std::shared_ptr<EDIT_POINTS> aEditPoints,
|
2023-12-06 13:08:05 +00:00
|
|
|
BOARD_COMMIT* aCommit );
|
2023-10-06 17:04:00 +00:00
|
|
|
|
|
|
|
virtual bool UpdateEditPoints( std::shared_ptr<EDIT_POINTS> aEditPoints );
|
|
|
|
|
|
|
|
const BOX2I GetBoundingBox() const override;
|
|
|
|
|
2023-10-09 14:22:16 +00:00
|
|
|
VECTOR2I GetPosition() const override { return m_origin; }
|
|
|
|
void SetPosition( const VECTOR2I& aPos ) override { m_origin = aPos; }
|
2023-10-06 17:04:00 +00:00
|
|
|
|
|
|
|
void Move( const VECTOR2I& aMoveVector ) override;
|
|
|
|
|
|
|
|
bool AddItem( BOARD_ITEM* aItem ) override;
|
|
|
|
|
|
|
|
LSET GetLayerSet() const override;
|
|
|
|
|
|
|
|
virtual void SetLayer( PCB_LAYER_ID aLayer ) override;
|
|
|
|
|
|
|
|
virtual wxString GetGeneratorType() const;
|
|
|
|
|
|
|
|
virtual const STRING_ANY_MAP GetProperties() const;
|
|
|
|
|
|
|
|
virtual void SetProperties( const STRING_ANY_MAP& aProps );
|
|
|
|
|
|
|
|
virtual std::vector<std::pair<wxString, wxVariant>> GetRowData();
|
|
|
|
|
2023-10-10 10:55:57 +00:00
|
|
|
virtual void ShowPropertiesDialog( PCB_BASE_EDIT_FRAME* aEditFrame ) {};
|
|
|
|
|
2023-10-06 17:04:00 +00:00
|
|
|
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
|
|
|
|
|
2023-10-19 00:31:01 +00:00
|
|
|
virtual wxString GetPluralName() const = 0;
|
|
|
|
|
2023-10-06 17:04:00 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
wxString GetClass() const override;
|
|
|
|
|
|
|
|
static inline bool ClassOf( const EDA_ITEM* aItem );
|
|
|
|
|
2023-10-19 00:31:01 +00:00
|
|
|
#ifdef GENERATOR_ORDER
|
2023-10-06 17:04:00 +00:00
|
|
|
int GetUpdateOrder() const { return m_updateOrder; }
|
|
|
|
void SetUpdateOrder( int aValue ) { m_updateOrder = aValue; }
|
2023-10-19 00:31:01 +00:00
|
|
|
#endif
|
2023-10-06 17:04:00 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
wxString m_generatorType;
|
|
|
|
|
|
|
|
VECTOR2I m_origin;
|
2023-10-19 00:31:01 +00:00
|
|
|
|
|
|
|
#ifdef GENERATOR_ORDER
|
2023-10-06 17:04:00 +00:00
|
|
|
int m_updateOrder = 0;
|
2023-10-19 00:31:01 +00:00
|
|
|
#endif
|
2023-10-06 17:04:00 +00:00
|
|
|
|
|
|
|
friend class GENERATORS_MGR;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* GENERATOR_H_ */
|