Skip to content

Commit

Permalink
Allow per-canvas non-overlap and routing buffers.
Browse files Browse the repository at this point in the history
This change removes the buffer distance (global) variables for padding around
shapes for routing and padding around shapes for non-overlap resolution.
These are now per-canvas options that can be adjusted through the Dunnart UI.
  • Loading branch information
mjwybrow committed Aug 13, 2012
1 parent cdb57da commit 8b7f45a
Show file tree
Hide file tree
Showing 43 changed files with 812 additions and 625 deletions.
187 changes: 187 additions & 0 deletions libavoid/actioninfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
/*
* vim: ts=4 sw=4 et tw=0 wm=0
*
* libavoid - Fast, Incremental, Object-avoiding Line Router
*
* Copyright (C) 2004-2011 Monash University
*
* This library is free software; you can redistribute it and/or
* 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.
* See the file LICENSE.LGPL distributed with the library.
*
* Licensees holding a valid commercial license may use this file in
* accordance with the commercial license agreement provided with the
* library.
*
* 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.
*
* Author(s): Michael Wybrow <mjwybrow@users.sourceforge.net>
*/


#include <algorithm>

#include "libavoid/actioninfo.h"
#include "libavoid/shape.h"
#include "libavoid/connector.h"
#include "libavoid/junction.h"

namespace Avoid {


ActionInfo::ActionInfo(ActionType t, ShapeRef *s, const Polygon& p, bool fM)
: type(t),
objPtr(s),
newPoly(p),
firstMove(fM)
{
COLA_ASSERT(type == ShapeMove);
}


ActionInfo::ActionInfo(ActionType t, ShapeRef *s)
: type(t),
objPtr(s)

{
COLA_ASSERT((type == ShapeAdd) || (type == ShapeRemove) ||
(type == ShapeMove));
}


ActionInfo::ActionInfo(ActionType t, JunctionRef *j, const Point& p)
: type(t),
objPtr(j),
newPosition(p)
{
COLA_ASSERT(type == JunctionMove);
}


ActionInfo::ActionInfo(ActionType t, JunctionRef *j)
: type(t),
objPtr(j)
{
COLA_ASSERT((type == JunctionAdd) || (type == JunctionRemove) ||
(type == JunctionMove));
}

ActionInfo::ActionInfo(ActionType t, ConnRef *c)
: type(t),
objPtr(c)
{
COLA_ASSERT(type == ConnChange);
}


ActionInfo::ActionInfo(ActionType t, ShapeConnectionPin *p)
: type(t),
objPtr(p)
{
COLA_ASSERT(type == ConnectionPinChange);
}


ActionInfo::~ActionInfo()
{
}


Obstacle *ActionInfo::obstacle(void) const
{
COLA_ASSERT((type == ShapeMove) || (type == ShapeAdd) ||
(type == ShapeRemove) || (type == JunctionMove) ||
(type == JunctionAdd) || (type == JunctionRemove));
return (static_cast<Obstacle *> (objPtr));
}


ShapeRef *ActionInfo::shape(void) const
{
return (dynamic_cast<ShapeRef *> (obstacle()));
}


ConnRef *ActionInfo::conn(void) const
{
COLA_ASSERT(type == ConnChange);
return (static_cast<ConnRef *> (objPtr));
}

JunctionRef *ActionInfo::junction(void) const
{
return (dynamic_cast<JunctionRef *> (obstacle()));
}


void ActionInfo::addConnEndUpdate(const unsigned int type,
const ConnEnd& connEnd, bool isConnPinMoveUpdate)
{
bool alreadyExists = false;
for (ConnUpdateList::iterator conn = conns.begin();
conn != conns.end(); ++conn)
{
// Look for an existing queued change to the same end.
if (conn->first == type)
{
// Found a queued change to the same endpoint of the
// connector. If this is a pin change as a result of a
// shape move, then leave the user created update
// that was found (since it may be moving the connection
// to connect to a different shape/pin. But if this is a
// user change, then overwrite the previous change.
alreadyExists = true;
if (!isConnPinMoveUpdate)
{
// Overwrite the queued change with this one.
conn->second = connEnd;
}
break;
}
}

if (!alreadyExists)
{
// Matching change not found, so add this one.
conns.push_back(std::make_pair(type, connEnd));
}
}


bool ActionInfo::operator==(const ActionInfo& rhs) const
{
return (type == rhs.type) && (objPtr == rhs.objPtr);
}


bool ActionInfo::operator<(const ActionInfo& rhs) const
{
if (type != rhs.type)
{
return type < rhs.type;
}

if (type == ConnChange)
{
return conn()->id() < rhs.conn()->id();
}
else if (type == ConnectionPinChange)
{
// NOTE Comparing pointers may not preserve the order of
// objects, but the order of Connection Pins is not
// used so this is not an issue here.
return objPtr < rhs.objPtr;
}
else
{
return obstacle()->id() < rhs.obstacle()->id();
}
}


}

88 changes: 88 additions & 0 deletions libavoid/actioninfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* vim: ts=4 sw=4 et tw=0 wm=0
*
* libavoid - Fast, Incremental, Object-avoiding Line Router
*
* Copyright (C) 2004-2011 Monash University
*
* This library is free software; you can redistribute it and/or
* 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.
* See the file LICENSE.LGPL distributed with the library.
*
* Licensees holding a valid commercial license may use this file in
* accordance with the commercial license agreement provided with the
* library.
*
* 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.
*
* Author(s): Michael Wybrow <mjwybrow@users.sourceforge.net>
*/

#ifndef AVOID_ACTIONINFO_H
#define AVOID_ACTIONINFO_H

#include <list>

#include "libavoid/actioninfo.h"
#include "libavoid/connend.h"
#include "libavoid/geomtypes.h"

namespace Avoid {

// This class is not intended for public use.
// It is used internally by Router to track actions performed on objects
// during transactions.



class ShapeRef;
class JunctionRef;


enum ActionType {
ShapeMove,
ShapeAdd,
ShapeRemove,
JunctionMove,
JunctionAdd,
JunctionRemove,
ConnChange,
ConnectionPinChange
};

typedef std::list<std::pair<unsigned int, ConnEnd> > ConnUpdateList;

class ActionInfo {
public:
ActionInfo(ActionType t, ShapeRef *s, const Polygon& p, bool fM);
ActionInfo(ActionType t, ShapeRef *s);
ActionInfo(ActionType t, JunctionRef *j, const Point& p);
ActionInfo(ActionType t, JunctionRef *j);
ActionInfo(ActionType t, ConnRef *c);
ActionInfo(ActionType t, ShapeConnectionPin *p);
~ActionInfo();
Obstacle *obstacle(void) const;
ShapeRef *shape(void) const;
ConnRef *conn(void) const;
JunctionRef *junction(void) const;
void addConnEndUpdate(const unsigned int type, const ConnEnd& connEnd,
bool isConnPinMoveUpdate);
bool operator==(const ActionInfo& rhs) const;
bool operator<(const ActionInfo& rhs) const;

ActionType type;
void *objPtr;
Polygon newPoly;
Point newPosition;
bool firstMove;
ConnUpdateList conns;
};
typedef std::list<ActionInfo> ActionInfoList;


}
#endif
Loading

0 comments on commit 8b7f45a

Please sign in to comment.