connector.cpp revision 0e39cdf0cc3195b77fa0effca0e2b07355fe1c0b
/*
* vim: ts=4 sw=4 et tw=0 wm=0
*
* libavoid - Fast, Incremental, Object-avoiding Line Router
* Copyright (C) 2004-2005 Michael Wybrow <mjwybrow@users.sourceforge.net>
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "libavoid/connector.h"
#include "libavoid/makepath.h"
#include "libavoid/visibility.h"
namespace Avoid {
, _srcId(0)
, _dstId(0)
, _needs_reroute_flag(true)
, _false_path(false)
, _active(false)
, _route_dist(0)
, _initialised(false)
, _connector(NULL)
{
// TODO: Store endpoints and details.
}
, _srcId(0)
, _dstId(0)
, _needs_reroute_flag(true)
, _false_path(false)
, _active(false)
, _route_dist(0)
, _initialised(false)
, _connector(NULL)
{
if (IncludeEndpoints)
{
bool isShape = false;
makeActive();
_initialised = true;
}
}
{
freeRoute();
if (_srcVert)
{
delete _srcVert;
}
if (_dstVert)
{
delete _dstVert;
}
if (_active)
{
makeInactive();
}
}
{
//assert(IncludeEndpoints);
if (!_initialised)
{
makeActive();
_initialised = true;
}
bool isShape = false;
{
if (_srcVert)
{
}
else
{
}
}
else // if (type == (unsigned int) VertID::dst)
{
if (_dstVert)
{
}
else
{
}
}
bool knownNew = false;
}
{
{
}
else // if (type == (unsigned int) VertID::dst)
{
}
}
void ConnRef::makeActive(void)
{
// Add to connRefs list.
_active = true;
}
void ConnRef::makeInactive(void)
{
// Remove from connRefs list.
_active = false;
}
{
{
}
}
{
return _route;
}
void ConnRef::calcRouteDist(void)
{
_route_dist = 0;
{
}
}
bool ConnRef::needsReroute(void)
{
return (_false_path || _needs_reroute_flag);
}
{
{
}
}
{
bool isShape = false;
makeActive();
_initialised = true;
}
{
return _srcVert;
}
{
return _dstVert;
}
bool ConnRef::isInitialised(void)
{
return _initialised;
}
void ConnRef::unInitialise(void)
{
makeInactive();
_initialised = false;
}
void ConnRef::removeFromGraph(void)
{
{
// For each vertex.
{
// Remove each visibility edge
delete (*edge);
}
{
// Remove each invisibility edge
delete (*edge);
}
}
}
{
_connector = ptr;
}
void ConnRef::handleInvalid(void)
{
if (_false_path || _needs_reroute_flag) {
if (_callback) {
}
}
}
void ConnRef::makePathInvalid(void)
{
_needs_reroute_flag = true;
}
{
if (!_false_path && !_needs_reroute_flag) {
// This connector is up to date.
return (int) false;
}
_false_path = false;
_needs_reroute_flag = false;
if (!IncludeEndpoints)
{
// Update as they have just been set by lateSetup.
bool knownNew = true;
}
bool *flag = &(_needs_reroute_flag);
bool result = true;
int pathlen = 1;
{
pathlen++;
if (i == NULL)
{
db_printf("Warning: Path not found...\n");
pathlen = 2;
if (InvisibilityGrph)
{
// TODO: Could we know this edge already?
edge->addCycleBlocker();
}
result = false;
break;
}
if (pathlen > 100)
{
exit(1);
}
}
int j = pathlen - 1;
{
if (InvisibilityGrph)
{
// TODO: Again, we could know this edge without searching.
}
else
{
_false_path = true;
}
}
// Would clear visibility for endpoints here if required.
return (int) result;
}
//============================================================================
const unsigned int ConnRef::runningToAndFrom =
const unsigned int type)
{
}
}
}
}
// It's intended this function is called after shape movement has
// happened to alert connectors that they need to be rerouted.
void callbackAllInvalidConnectors(void)
{
(*i)->handleInvalid();
}
}
}