2010-03-09 09:24:29 -06:00
|
|
|
// -*- C++ -*-
|
|
|
|
//
|
|
|
|
// This file is part of the Coriolis Software.
|
2016-03-06 05:36:18 -06:00
|
|
|
// Copyright (c) UPMC 2008-2016, All Rights Reserved
|
2010-03-09 09:24:29 -06:00
|
|
|
//
|
2013-12-03 18:58:58 -06:00
|
|
|
// +-----------------------------------------------------------------+
|
2010-03-09 09:24:29 -06:00
|
|
|
// | C O R I O L I S |
|
|
|
|
// | K a t a b a t i c - Routing Toolbox |
|
|
|
|
// | |
|
|
|
|
// | Author : Jean-Paul CHAPUT |
|
2013-12-03 18:58:58 -06:00
|
|
|
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
2010-03-09 09:24:29 -06:00
|
|
|
// | =============================================================== |
|
|
|
|
// | C++ Module : "./AutoSegments.cpp" |
|
2013-12-03 18:58:58 -06:00
|
|
|
// +-----------------------------------------------------------------+
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
|
|
|
#include "hurricane/Error.h"
|
|
|
|
#include "katabatic/AutoContact.h"
|
|
|
|
#include "katabatic/AutoSegment.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace Katabatic {
|
|
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using Hurricane::tab;
|
|
|
|
using Hurricane::_TName;
|
|
|
|
using Hurricane::Error;
|
|
|
|
using Hurricane::ForEachIterator;
|
|
|
|
using Hurricane::Hook;
|
|
|
|
using Hurricane::Contact;
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// Class : "Katabatic::AutoSegmentStack".
|
|
|
|
|
|
|
|
void AutoSegmentStack::push ( AutoContact* contact, AutoSegment* segment )
|
|
|
|
{
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(145,0) << "Stacking " << contact << " + " << segment << endl;
|
2013-12-03 18:58:58 -06:00
|
|
|
push_back( make_pair(contact,segment) );
|
2010-03-09 09:24:29 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// Class : "Katabatic::AutoSegments_OnContact".
|
|
|
|
|
|
|
|
AutoSegments_OnContact::Locator::Locator ( AutoSegment* master, Contact* contact )
|
|
|
|
: AutoSegmentHL()
|
2013-12-03 18:58:58 -06:00
|
|
|
, _master (master)
|
|
|
|
, _element (NULL)
|
2010-03-09 09:24:29 -06:00
|
|
|
{
|
|
|
|
_hook = contact->getBodyHook()->getPreviousMasterHook();
|
2013-12-03 18:58:58 -06:00
|
|
|
progress();
|
2010-03-09 09:24:29 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AutoSegmentHL* AutoSegments_OnContact::Locator::getClone () const
|
2013-12-03 18:58:58 -06:00
|
|
|
{ return new Locator(*this); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
|
|
|
AutoSegment* AutoSegments_OnContact::Locator::getElement () const
|
2013-12-03 18:58:58 -06:00
|
|
|
{ return _element; }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
|
|
|
bool AutoSegments_OnContact::Locator::isValid () const
|
2013-12-03 18:58:58 -06:00
|
|
|
{ return !_hook; }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
|
|
|
void AutoSegments_OnContact::Locator::progress ()
|
|
|
|
{
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(145,0) << "AutoSegments_OnContact::Locator::progress()" << endl;
|
2010-03-09 09:24:29 -06:00
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
while (_hook and not _hook->isMaster()) {
|
2010-03-09 09:24:29 -06:00
|
|
|
_hook = _hook->getNextHook();
|
|
|
|
_element = NULL;
|
|
|
|
|
|
|
|
if ( _hook->isMaster() ) { _hook = NULL; break; }
|
|
|
|
|
|
|
|
Segment* segment = dynamic_cast<Segment*>( _hook->getComponent() );
|
2013-12-03 18:58:58 -06:00
|
|
|
if (segment) _element = Session::lookup( segment );
|
2010-03-09 09:24:29 -06:00
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
if (not _element or (_element == _master)) continue;
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string AutoSegments_OnContact::Locator::_getString () const
|
|
|
|
{
|
|
|
|
string s = "<" + _TName("AutoSegments_OnContact::Locator")
|
|
|
|
+ getString(_element)
|
|
|
|
+ ">";
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AutoSegmentHC* AutoSegments_OnContact::getClone () const
|
2013-12-03 18:58:58 -06:00
|
|
|
{ return new AutoSegments_OnContact(*this); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
|
|
|
AutoSegmentHL* AutoSegments_OnContact::getLocator () const
|
2013-12-03 18:58:58 -06:00
|
|
|
{ return new Locator(_master,_contact); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
|
|
|
string AutoSegments_OnContact::_getString () const
|
|
|
|
{
|
|
|
|
string s = "<" + _TName("AutoSegments_OnContact") + " "
|
|
|
|
+ getString(_master)
|
|
|
|
+ ">";
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
2013-12-03 18:58:58 -06:00
|
|
|
// Class : "AutoSegments_Aligneds".
|
2010-03-09 09:24:29 -06:00
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
AutoSegments_Aligneds::Locator::Locator ( AutoSegment* segment, unsigned int flags )
|
2010-03-09 09:24:29 -06:00
|
|
|
: AutoSegmentHL()
|
2013-12-03 18:58:58 -06:00
|
|
|
, _flags (flags)
|
2010-03-09 09:24:29 -06:00
|
|
|
, _master(segment)
|
2013-12-03 18:58:58 -06:00
|
|
|
, _stack ()
|
2010-03-09 09:24:29 -06:00
|
|
|
{
|
2013-12-03 18:58:58 -06:00
|
|
|
if (not _master) return;
|
|
|
|
_flags |= (_master->isHorizontal()) ? KbHorizontal : KbVertical;
|
|
|
|
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(145,0) << "AutoSegments_Aligneds::Locator::Locator() - _flags:" << _flags << endl;
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
AutoContact* contact = segment->getAutoSource();
|
2013-12-03 18:58:58 -06:00
|
|
|
if (contact) _stack.push( contact, segment );
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
contact = segment->getAutoTarget();
|
2013-12-03 18:58:58 -06:00
|
|
|
if (contact) _stack.push( contact, segment );
|
2010-03-09 09:24:29 -06:00
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
progress();
|
2010-03-09 09:24:29 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
AutoSegmentHL* AutoSegments_Aligneds::Locator::getClone () const
|
|
|
|
{ return new Locator(*this); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
bool AutoSegments_Aligneds::Locator::isValid () const
|
|
|
|
{ return not _stack.isEmpty(); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
void AutoSegments_Aligneds::Locator::progress ()
|
2010-03-09 09:24:29 -06:00
|
|
|
{
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(145,0) << "AutoSegments_Aligneds::Locator::progress()" << endl;
|
2010-03-09 09:24:29 -06:00
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
while (not _stack.isEmpty()) {
|
2010-03-09 09:24:29 -06:00
|
|
|
AutoContact* sourceContact = _stack.getAutoContact ();
|
|
|
|
AutoSegment* sourceSegment = _stack.getAutoSegment ();
|
|
|
|
|
|
|
|
_stack.pop ();
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
LocatorHelper helper (sourceContact, _flags);
|
|
|
|
for ( ; helper.isValid() ; helper.progress() ) {
|
|
|
|
AutoSegment* currentSegment = helper.getSegment();
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(145,0) << "Looking at: " << currentSegment << endl;
|
2010-03-09 09:24:29 -06:00
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
if (currentSegment == sourceSegment) continue;
|
2010-03-09 09:24:29 -06:00
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
if ( (not (_flags & KbNoCheckLayer))
|
|
|
|
and AutoSegment::areAlignedsAndDiffLayer(currentSegment,_master)) {
|
|
|
|
cerr << Error("Aligned segments not in same layer (aligneds locator)\n"
|
|
|
|
" %s\n"
|
|
|
|
" %s."
|
|
|
|
,getString(_master).c_str()
|
|
|
|
,getString(currentSegment).c_str()) << endl;
|
2010-03-09 09:24:29 -06:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
AutoContact* targetContact = currentSegment->getOppositeAnchor( sourceContact );
|
|
|
|
if (targetContact) _stack.push( targetContact, currentSegment );
|
2010-03-09 09:24:29 -06:00
|
|
|
}
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
if (_stack.getAutoSegment() == _master) continue;
|
|
|
|
break;
|
2010-03-09 09:24:29 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
string AutoSegments_Aligneds::Locator::_getString () const
|
2010-03-09 09:24:29 -06:00
|
|
|
{
|
2013-12-03 18:58:58 -06:00
|
|
|
string s = "<" + _TName("AutoSegments_Aligneds::Locator") + ">";
|
2010-03-09 09:24:29 -06:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
AutoSegmentHC* AutoSegments_Aligneds::getClone () const
|
|
|
|
{ return new AutoSegments_Aligneds(*this); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
AutoSegmentHL* AutoSegments_Aligneds::getLocator () const
|
|
|
|
{ return new Locator(_segment,_flags); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
AutoSegment* AutoSegments_Aligneds::Locator::getElement () const
|
|
|
|
{ return _stack.getAutoSegment(); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
string AutoSegments_Aligneds::_getString () const
|
2010-03-09 09:24:29 -06:00
|
|
|
{
|
2013-12-03 18:58:58 -06:00
|
|
|
string s = "<" + _TName("AutoSegments_Aligneds") + " "
|
2010-03-09 09:24:29 -06:00
|
|
|
+ getString(_segment)
|
|
|
|
+ ">";
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
2013-12-03 18:58:58 -06:00
|
|
|
// Class : "AutoSegments_Perpandiculars".
|
2010-03-09 09:24:29 -06:00
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
AutoSegments_Perpandiculars::Locator::Locator ( AutoSegment* master )
|
2010-03-09 09:24:29 -06:00
|
|
|
: AutoSegmentHL()
|
2013-12-03 18:58:58 -06:00
|
|
|
, _flags (KbWithPerpands)
|
|
|
|
, _master (master)
|
|
|
|
, _stack ()
|
2010-03-09 09:24:29 -06:00
|
|
|
, _perpandiculars()
|
|
|
|
{
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(145,0) << "AutoSegments_Perpandiculars::Locator::Locator()" << endl;
|
|
|
|
cdebug_log(145,0) << " " << _master << endl;
|
2010-03-09 09:24:29 -06:00
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
if (not _master) return;
|
|
|
|
if (_master->isHorizontal()) _flags |= KbHorizontal;
|
|
|
|
else _flags |= KbVertical;
|
2010-03-09 09:24:29 -06:00
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
AutoContact* contact = _master->getAutoSource();
|
|
|
|
if ( contact ) _stack.push( contact, _master );
|
2010-03-09 09:24:29 -06:00
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
contact = _master->getAutoTarget();
|
|
|
|
if ( contact ) _stack.push( contact, _master );
|
2010-03-09 09:24:29 -06:00
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
progress();
|
2010-03-09 09:24:29 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
AutoSegment* AutoSegments_Perpandiculars::Locator::getElement () const
|
2010-03-09 09:24:29 -06:00
|
|
|
{
|
2013-12-03 18:58:58 -06:00
|
|
|
if (_perpandiculars.empty()) return NULL;
|
|
|
|
return _perpandiculars.back();
|
2010-03-09 09:24:29 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
void AutoSegments_Perpandiculars::Locator::progress ()
|
2010-03-09 09:24:29 -06:00
|
|
|
{
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(145,0) << "AutoSegments_Perpandiculars::Locator::progress()" << endl;
|
2010-03-09 09:24:29 -06:00
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
if (not _perpandiculars.empty()) _perpandiculars.pop_back();
|
|
|
|
if (not _perpandiculars.empty()) return;
|
2010-03-09 09:24:29 -06:00
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
while ( not _stack.isEmpty() ) {
|
|
|
|
AutoContact* sourceContact = _stack.getAutoContact();
|
|
|
|
AutoSegment* sourceSegment = _stack.getAutoSegment();
|
2010-03-09 09:24:29 -06:00
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
_stack.pop();
|
2010-03-09 09:24:29 -06:00
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
LocatorHelper helper (sourceContact, _flags);
|
|
|
|
for ( ; helper.isValid() ; helper.progress() ) {
|
|
|
|
AutoSegment* currentSegment = helper.getSegment();
|
|
|
|
if (currentSegment == sourceSegment) continue;
|
2010-03-09 09:24:29 -06:00
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
if (AutoSegment::areAligneds(currentSegment,_master)) {
|
|
|
|
AutoContact* targetContact = currentSegment->getOppositeAnchor( sourceContact );
|
|
|
|
if (targetContact) {
|
|
|
|
if ( (_master->isHorizontal() and sourceContact->isHTee())
|
|
|
|
or (_master->isVertical () and sourceContact->isVTee()) ) {
|
|
|
|
if (AutoSegment::areAlignedsAndDiffLayer(currentSegment,_master)) {
|
|
|
|
cerr << Error("Aligned segments not in same layer (perpandicular locator)\n"
|
|
|
|
" %s\n"
|
|
|
|
" %s."
|
|
|
|
,getString(_master).c_str()
|
|
|
|
,getString(currentSegment).c_str()) << endl;
|
|
|
|
continue;
|
|
|
|
}
|
2010-03-09 09:24:29 -06:00
|
|
|
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(145,0) << "Stacking target. " << endl;
|
2013-12-03 18:58:58 -06:00
|
|
|
_stack.push( targetContact, currentSegment );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_perpandiculars.push_back( currentSegment );
|
2010-03-09 09:24:29 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
if (_stack.isEmpty()) break;
|
|
|
|
if (_stack.getAutoSegment() == _master) continue;
|
|
|
|
if (not _perpandiculars.empty()) break;
|
2010-03-09 09:24:29 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
AutoSegmentHL* AutoSegments_Perpandiculars::Locator::getClone () const
|
|
|
|
{ return new Locator(*this); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
bool AutoSegments_Perpandiculars::Locator::isValid () const
|
|
|
|
{ return not _perpandiculars.empty(); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
AutoSegmentHC* AutoSegments_Perpandiculars::getClone () const
|
|
|
|
{ return new AutoSegments_Perpandiculars(*this); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
AutoSegmentHL* AutoSegments_Perpandiculars::getLocator () const
|
|
|
|
{ return new Locator(_segment); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
string AutoSegments_Perpandiculars::Locator::_getString () const
|
2010-03-09 09:24:29 -06:00
|
|
|
{
|
2013-12-03 18:58:58 -06:00
|
|
|
string s = "<" + _TName("AutoSegments_Perpandiculars::Locator") + ">";
|
2010-03-09 09:24:29 -06:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
string AutoSegments_Perpandiculars::_getString () const
|
2010-03-09 09:24:29 -06:00
|
|
|
{
|
2013-12-03 18:58:58 -06:00
|
|
|
string s = "<" + _TName("AutoSegments_Perpandiculars") + " "
|
2010-03-09 09:24:29 -06:00
|
|
|
+ getString(_segment)
|
|
|
|
+ ">";
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// Class : "AutoSegments_AnchorOnGCell".
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
AutoSegments_AnchorOnGCell::Locator::Locator ( GCell* fcell, unsigned int flags )
|
2010-03-09 09:24:29 -06:00
|
|
|
: AutoSegmentHL()
|
2013-12-03 18:58:58 -06:00
|
|
|
, _flags (flags)
|
|
|
|
, _itContact (fcell->getContacts().begin())
|
|
|
|
, _itEnd (fcell->getContacts().end())
|
2010-03-09 09:24:29 -06:00
|
|
|
, _hookLocator(NULL)
|
2013-12-03 18:58:58 -06:00
|
|
|
, _element (NULL)
|
|
|
|
{ progress(); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
|
|
|
AutoSegments_AnchorOnGCell::Locator::~Locator ()
|
2013-12-03 18:58:58 -06:00
|
|
|
{ if (_hookLocator) delete _hookLocator; }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
|
|
|
AutoSegment* AutoSegments_AnchorOnGCell::Locator::getElement () const
|
2013-12-03 18:58:58 -06:00
|
|
|
{ return _element; }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
|
|
|
AutoSegmentHL* AutoSegments_AnchorOnGCell::Locator::getClone () const
|
2013-12-03 18:58:58 -06:00
|
|
|
{ return new Locator(*this); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
|
|
|
bool AutoSegments_AnchorOnGCell::Locator::isValid () const
|
2013-12-03 18:58:58 -06:00
|
|
|
{ return _element != NULL; }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
|
|
|
void AutoSegments_AnchorOnGCell::Locator::progress ()
|
|
|
|
{
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(145,1) << "AutoSegments_AnchorOnGCell::Locator::progress()" << endl;
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
while ( true ) {
|
2013-12-03 18:58:58 -06:00
|
|
|
if (_hookLocator == NULL) {
|
|
|
|
if (_itContact == _itEnd) {
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(145,0) << "No more AutoContacts" << endl;
|
|
|
|
cdebug_tabw(145,-1);
|
2010-03-09 09:24:29 -06:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(145,0) << *_itContact << endl;
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
_hookLocator = (*_itContact)->getBodyHook()->getSlaveHooks().getLocator();
|
|
|
|
_itContact++;
|
|
|
|
} else {
|
2013-12-03 18:58:58 -06:00
|
|
|
_hookLocator->progress();
|
2010-03-09 09:24:29 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
while ( _hookLocator->isValid() ) {
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(145,0) << _hookLocator->getElement() << endl;
|
2010-03-09 09:24:29 -06:00
|
|
|
Hook* hook = dynamic_cast<Segment::SourceHook*>(_hookLocator->getElement());
|
2013-12-03 18:58:58 -06:00
|
|
|
if (hook) {
|
Support of RoutingGauge, part 2.
In Katabatic & Kite, remove all hard-coded values related to track pitches.
* New: In <Session>, add more convenience function to access RoutingGauge
characteristics.
* New: In <AutoSegment>, <AutoContact>, add support for the "depth spin",
that is, if the source/target contacts are going "top" or "down".
Used to compute the perpandicular pitch. Need a small modification
of the revalidation mechanism. The observers of <AutoSegment> are
notified when the spin changes.
* New: In <AutoSegment>, the getPPitch() method allow to compute the
"perpandicular pitch". For now it is simply the greatest from the
source perpandicular pitch and the target perpandicular pitch.
Make uses of the "depth spin".
* New: In <TrackElement>, <TrackSegment>, cache the perpandicular pitch.
Updated through the notification from the observable.
2014-05-19 10:58:38 -05:00
|
|
|
if ( ((_flags & KbSource) and (dynamic_cast<Segment::SourceHook*>(hook)))
|
|
|
|
or ((_flags & KbTarget) and (dynamic_cast<Segment::TargetHook*>(hook))) ) {
|
2013-12-03 18:58:58 -06:00
|
|
|
_element = Session::lookup( static_cast<Segment*>(hook->getComponent()) );
|
|
|
|
|
|
|
|
if (_element->isHorizontal()) {
|
2016-06-11 14:56:12 -05:00
|
|
|
if (_flags & KbHorizontal) { cdebug_tabw(145,-1); return; }
|
2013-12-03 18:58:58 -06:00
|
|
|
} else
|
2016-06-11 14:56:12 -05:00
|
|
|
if (_flags & KbVertical) { cdebug_tabw(145,-1); return; }
|
2013-12-03 18:58:58 -06:00
|
|
|
}
|
2010-03-09 09:24:29 -06:00
|
|
|
}
|
|
|
|
_hookLocator->progress();
|
|
|
|
}
|
|
|
|
_hookLocator = NULL;
|
|
|
|
_element = NULL;
|
|
|
|
}
|
|
|
|
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_tabw(145,-1);
|
2010-03-09 09:24:29 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string AutoSegments_AnchorOnGCell::Locator::_getString () const
|
|
|
|
{
|
2013-12-03 18:58:58 -06:00
|
|
|
string s = "<" + _TName("AutoSegments_AnchorOnGCell::Locator") + ">";
|
2010-03-09 09:24:29 -06:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AutoSegmentHC* AutoSegments_AnchorOnGCell::getClone () const
|
2013-12-03 18:58:58 -06:00
|
|
|
{ return new AutoSegments_AnchorOnGCell(*this); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
|
|
|
AutoSegmentHL* AutoSegments_AnchorOnGCell::getLocator () const
|
2013-12-03 18:58:58 -06:00
|
|
|
{ return new Locator(_fcell,_flags); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
|
|
|
string AutoSegments_AnchorOnGCell::_getString () const
|
|
|
|
{
|
|
|
|
string s = "<" + _TName("AutoSegments_AnchorOnGCell") + " "
|
|
|
|
+ getString(_fcell)
|
|
|
|
+ ">";
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
2013-12-03 18:58:58 -06:00
|
|
|
// Class : "Katabatic::AutoSegments_CachedOnContact".
|
2010-03-09 09:24:29 -06:00
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
AutoSegments_CachedOnContact::Locator::Locator ( AutoContact* sourceContact, unsigned int direction )
|
|
|
|
: AutoSegmentHL()
|
|
|
|
, _helper(new LocatorHelper(sourceContact,direction))
|
|
|
|
{ }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
AutoSegments_CachedOnContact::Locator::~Locator ()
|
|
|
|
{ delete _helper; }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
AutoSegment* AutoSegments_CachedOnContact::Locator::getElement () const
|
|
|
|
{ return _helper->getSegment(); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
AutoSegmentHL* AutoSegments_CachedOnContact::Locator::getClone () const
|
|
|
|
{ return new Locator(*this); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
bool AutoSegments_CachedOnContact::Locator::isValid () const
|
|
|
|
{ return _helper->isValid(); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
void AutoSegments_CachedOnContact::Locator::progress ()
|
2010-03-09 09:24:29 -06:00
|
|
|
{
|
2016-06-11 14:56:12 -05:00
|
|
|
cdebug_log(145,0) << "AutoSegments_CachedOnContact::Locator::progress()" << endl;
|
2013-12-03 18:58:58 -06:00
|
|
|
_helper->progress();
|
2010-03-09 09:24:29 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
AutoSegmentHL* AutoSegments_CachedOnContact::getLocator () const
|
|
|
|
{ return new Locator(_sourceContact,_direction); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
AutoSegmentHC* AutoSegments_CachedOnContact::getClone () const
|
|
|
|
{ return new AutoSegments_CachedOnContact(*this); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
string AutoSegments_CachedOnContact::Locator::_getString () const
|
2010-03-09 09:24:29 -06:00
|
|
|
{
|
2013-12-03 18:58:58 -06:00
|
|
|
string s = "<" + _TName("AutoSegments_CachedOnContact::Locator") + ">";
|
2010-03-09 09:24:29 -06:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
string AutoSegments_CachedOnContact::_getString () const
|
2010-03-09 09:24:29 -06:00
|
|
|
{
|
2013-12-03 18:58:58 -06:00
|
|
|
string s = "<" + _TName("AutoSegments_CachedOnContact") + " "
|
2010-03-09 09:24:29 -06:00
|
|
|
+ getString(_sourceContact)
|
|
|
|
+ ">";
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// Class : "AutoSegments_IsAccountable".
|
|
|
|
|
|
|
|
AutoSegmentHF* AutoSegments_IsAccountable::getClone () const
|
2013-12-03 18:58:58 -06:00
|
|
|
{ return new AutoSegments_IsAccountable(); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
|
|
|
bool AutoSegments_IsAccountable::accept ( AutoSegment* segment ) const
|
2013-12-03 18:58:58 -06:00
|
|
|
{ return segment->isCanonical(); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
|
|
|
string AutoSegments_IsAccountable::_getString () const
|
2013-12-03 18:58:58 -06:00
|
|
|
{ return "<AutoSegments_IsAccountable>"; }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// Class : "AutoSegments_InDirection".
|
|
|
|
|
|
|
|
|
|
|
|
AutoSegmentHF* AutoSegments_InDirection::getClone () const
|
2013-12-03 18:58:58 -06:00
|
|
|
{ return new AutoSegments_InDirection(_direction); }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
|
|
|
bool AutoSegments_InDirection::accept ( AutoSegment* segment ) const
|
|
|
|
{
|
2013-12-03 18:58:58 -06:00
|
|
|
return ( segment->isHorizontal() and (_direction & KbHorizontal) )
|
|
|
|
or ( segment->isVertical () and (_direction & KbVertical ) );
|
2010-03-09 09:24:29 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string AutoSegments_InDirection::_getString () const
|
2013-12-03 18:58:58 -06:00
|
|
|
{ return "<AutoSegments_InDirection>"; }
|
2010-03-09 09:24:29 -06:00
|
|
|
|
|
|
|
|
2013-12-03 18:58:58 -06:00
|
|
|
} // Katabatic namespace.
|