conn-avoid-ref.cpp revision ef610fdbfb424e7ad204ac9de142c05bb986e1dc
/*
* A class for handling shape interaction with libavoid.
*
* Authors:
* Michael Wybrow <mjwybrow@users.sourceforge.net>
*
* Copyright (C) 2005 Michael Wybrow
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <cstring>
#include <string>
#include <iostream>
#include "sp-item.h"
#include "2geom/crossing.h"
#include "2geom/convex-cover.h"
#include "helper/geom-curves.h"
#include "svg/stringstream.h"
#include "conn-avoid-ref.h"
#include "connection-points.h"
#include "sp-conn-end.h"
#include "sp-path.h"
#include "libavoid/connector.h"
#include "libavoid/geomtypes.h"
#include "document.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "sp-namedview.h"
#include "sp-item-group.h"
#include "inkscape.h"
, setting(false)
, new_setting(false)
{
}
SPAvoidRef::~SPAvoidRef()
{
// If the document is being destroyed then the router instance
// and the ShapeRefs will have been destroyed with it.
if (shapeRef && routerInstanceExists) {
delete shapeRef;
}
}
{
if (SP_OBJECT_IS_CLONED(item)) {
// Don't keep avoidance information for cloned objects.
return;
}
new_setting = false;
new_setting = true;
}
}
{
{
const ConnectionPoint& p = i->second;
}
}
{
if (value)
{
/* Rebuild the connection points list.
Update the connectors for which
the endpoint has changed.
*/
/* Mark this connection point as seen, so we can delete
the other ones.
*/
{
/* An already existing connection point.
Check to see if changed, and, if it is
the case, trigger connector update for
the connector attached to this connection
point. This is done by adding the
connection point to a list of connection
points to be updated.
*/
// The connection point got updated.
// Put it in the update list.
}
++iter;
}
/* Delete the connection points that didn't appear
in the new connection point list.
*/
}
else
{
/* Delete all the user-defined connection points
Actually we do this by adding them to the list
of connection points to be deleted.
*/
}
/* Act upon updates and deletes.
*/
// Nothing to do, just return.
return;
// Get a list of attached connectors.
{
} else {
}
}
}
}
}
}
// Remove all deleted connection points
}
{
item->updateRepr();
doc->ensure_up_to_date();
}
{
bool first = true;
int newId = 1;
if ( connection_points.size() )
{
{
if ( first )
{
first = false;
}
else
++it;
{
break;
}
}
}
if ( first )
{
first = false;
}
else
}
{
{
bool first = true;
for (IdConnectionPointMap::iterator it = connection_points.begin(); it != connection_points.end(); ++it)
{
else
if ( first )
{
first = false;
}
else
}
}
}
{
bool first = true;
for (IdConnectionPointMap::iterator it = connection_points.begin(); it != connection_points.end(); ++it) {
if ( first ) {
first = false;
} else {
}
}
}
}
}
void SPAvoidRef::handleSettingChange(void)
{
return;
}
// We don't want to go any further if the active desktop's document
// isn't the same as the document that this item is part of. This
// case can happen if a new document is loaded from the file chooser
// or via the recent file menu. In this case, we can end up here
// as a rersult of a sp_document_ensure_up_to_date performed on a
// document not yet attached to the active desktop.
return;
}
if (new_setting == setting) {
// Don't need to make any changes
return;
}
if (new_setting) {
//const char *id = SP_OBJECT_REPR(item)->attribute("id");
// Get a unique ID for the item.
}
}
else
{
delete shapeRef;
}
}
{
g_warning("getAttachedShapes: Object with id=\"%s\" is not "
"found. Skipping.", connId);
continue;
}
}
return list;
}
{
g_warning("getAttachedConnectors: Object with id=\"%s\" is not "
"found. Skipping.", connId);
continue;
}
}
return list;
}
{
// TODO investigate why this was asking for the active desktop:
if ( type == ConnPointDefault )
{
// For now, just default to the centre of the item
}
else
{
// Get coordinates from the list of connection points
// that are attached to the item
}
return pos;
}
{
return false;
else
{
if ( type == ConnPointDefault )
return false;
else
{
}
else
}
return true;
}
{
// The number of segments to use for not straight curves approximation
const unsigned NUM_SEGS = 4;
// The structure to hold the output
// Iterate over all curves, adding the endpoints for linear curves and
// sampling the other curves
double at;
at = 0;
{
{
if (at <= 1.0 )
else
{
at = 0.0;
++cit;
}
}
else
{
++cit;
}
++pit;
}
return poly_points;
}
static std::vector<Geom::Point> approxItemWithPoints(SPItem const *item, const Geom::Matrix& item_transform)
{
// The structure to hold the output
if (SP_IS_GROUP(item))
{
// consider all first-order children
std::vector<Geom::Point> child_points = approxItemWithPoints(child_item, item_transform * child_item->transform);
}
}
else if (SP_IS_SHAPE(item))
{
// make sure it has an associated curve
if (item_curve)
{
// apply transformations (up to common ancestor)
item_curve->unref();
}
}
return poly_points;
}
{
// create convex hull from all sampled points
// enlarge path by "desktop->namedview->connector_spacing"
// store expanded convex hull in Avoid::Polygn
for (int i = 0; i <= hull_size; ++i)
{
// determine the intersection point
if (int_pt)
{
Avoid::Point avoid_pt((parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X],
}
else
{
// something went wrong...
}
}
return poly;
}
bool initialised)
{
if (SP_IS_ITEM(child) &&
)
{
}
}
}
return list;
}
{
}
}
{
// Don't count this as changes to the document,
// it is basically just late initialisation.
bool initialised = false;
}
if (items) {
}
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :