2020-02-28 22:08:34 +00:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2020 CERN
|
2024-01-02 14:54:11 +00:00
|
|
|
* Copyright (C) 2016-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-02-28 22:08:34 +00:00
|
|
|
* Author: Tomasz Wlostowski <tomasz.wlostowski@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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PNS_DRAG_ALGO_H
|
|
|
|
#define __PNS_DRAG_ALGO_H
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <math/vector2d.h>
|
|
|
|
|
2023-01-27 08:06:33 +00:00
|
|
|
#include "pns_router.h"
|
2020-02-28 22:08:34 +00:00
|
|
|
#include "pns_algo_base.h"
|
|
|
|
#include "pns_itemset.h"
|
|
|
|
#include "pns_layerset.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace PNS {
|
|
|
|
|
|
|
|
class NODE;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DRAG_ALGO
|
|
|
|
*
|
|
|
|
* Base class for item dragging algorithms.
|
|
|
|
*/
|
|
|
|
class DRAG_ALGO : public ALGO_BASE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DRAG_ALGO( ROUTER* aRouter ) :
|
2020-11-01 19:56:54 +00:00
|
|
|
ALGO_BASE( aRouter ),
|
|
|
|
m_world( nullptr )
|
2020-02-28 22:08:34 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-11-01 19:56:54 +00:00
|
|
|
~DRAG_ALGO()
|
|
|
|
{
|
|
|
|
}
|
2020-02-28 22:08:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetWorld()
|
|
|
|
*
|
|
|
|
* Sets the board to work on.
|
|
|
|
*/
|
|
|
|
virtual void SetWorld( NODE* aWorld )
|
|
|
|
{
|
|
|
|
m_world = aWorld;
|
|
|
|
}
|
|
|
|
|
2020-11-01 19:56:54 +00:00
|
|
|
/**
|
|
|
|
* Function Start()
|
|
|
|
*
|
2021-01-04 18:06:39 +00:00
|
|
|
* Starts routing a single track at point aP, taking item aStartItem as anchor (unless NULL).
|
|
|
|
* Returns true if a dragging operation has started.
|
2020-11-01 19:56:54 +00:00
|
|
|
*/
|
|
|
|
virtual bool Start( const VECTOR2I& aP, ITEM_SET& aPrimitives ) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Drag()
|
|
|
|
*
|
|
|
|
* Drags the current segment/corner/via to the point aP.
|
|
|
|
* @return true, if dragging finished with success.
|
|
|
|
*/
|
|
|
|
virtual bool Drag( const VECTOR2I& aP ) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function FixRoute()
|
|
|
|
*
|
|
|
|
* Checks if the result of current dragging operation is correct
|
|
|
|
* and eventually commits it to the world.
|
|
|
|
* @return true, if dragging finished with success.
|
|
|
|
*/
|
2024-01-02 14:54:11 +00:00
|
|
|
virtual bool FixRoute( bool aForceCommit ) = 0;
|
2020-11-01 19:56:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function CurrentNode()
|
|
|
|
*
|
2021-01-04 18:06:39 +00:00
|
|
|
* Returns the most recent world state, including all items changed by dragging operation.
|
2020-11-01 19:56:54 +00:00
|
|
|
*/
|
|
|
|
virtual NODE* CurrentNode() const = 0;
|
|
|
|
|
2020-11-08 17:16:00 +00:00
|
|
|
/**
|
|
|
|
* Function CurrentNets()
|
|
|
|
*
|
2023-08-22 12:06:33 +00:00
|
|
|
* Returns the net(s) of currently dragged item(s).
|
2020-11-08 17:16:00 +00:00
|
|
|
*/
|
2023-08-22 12:06:33 +00:00
|
|
|
virtual const std::vector<NET_HANDLE> CurrentNets() const = 0;
|
2020-11-01 19:56:54 +00:00
|
|
|
|
2020-11-08 17:16:00 +00:00
|
|
|
/**
|
|
|
|
* Function CurrentLayer()
|
|
|
|
*
|
|
|
|
* Returns the layer of currently dragged item(s).
|
|
|
|
*/
|
|
|
|
virtual int CurrentLayer() const = 0;
|
|
|
|
|
2020-11-01 19:56:54 +00:00
|
|
|
/**
|
|
|
|
* Function Traces()
|
|
|
|
*
|
|
|
|
* Returns the set of dragged items.
|
|
|
|
*/
|
|
|
|
virtual const ITEM_SET Traces() = 0;
|
2020-02-28 22:08:34 +00:00
|
|
|
|
2023-01-27 08:06:33 +00:00
|
|
|
virtual void SetMode( PNS::DRAG_MODE aDragMode ){};
|
|
|
|
|
|
|
|
virtual PNS::DRAG_MODE Mode() const = 0;
|
2020-02-28 22:08:34 +00:00
|
|
|
|
2024-01-02 14:54:11 +00:00
|
|
|
virtual bool GetForceMarkObstaclesMode( bool* aDragStatus ) const = 0;
|
|
|
|
|
2020-02-28 22:08:34 +00:00
|
|
|
protected:
|
2020-11-01 19:56:54 +00:00
|
|
|
NODE* m_world;
|
2020-02-28 22:08:34 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace PNS
|
|
|
|
|
|
|
|
#endif
|