conn-avoid-ref.cpp revision 9049704992fc21c607b00d83bb673dca0fea6300
/*
* A class for handling shape interaction with libavoid.
*
* Authors:
* Michael Wybrow <mjwybrow@users.sourceforge.net>
* Abhishek Sharma
*
* 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 "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 "document-undo.h"
#include "sp-namedview.h"
#include "sp-item-group.h"
#include "inkscape.h"
#include "verbs.h"
using Inkscape::DocumentUndo;
, 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) {
// Deleting the shapeRef will remove it completely from
// an existing Router instance.
delete shapeRef;
}
}
{
// Don't keep avoidance information for cloned objects.
new_setting = false;
new_setting = true;
}
}
}
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 ensureUpToDate 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) {
// Get a unique ID for the item.
}
}
else
{
// Deleting the shapeRef will remove it completely from
// an existing Router instance.
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;
}
{
// the center is all we are interested in now; we used to care
// about non-center points, but that's moot.
}
{
// 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::Affine& 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
try {
if (int_pt)
{
Avoid::Point avoid_pt((parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X],
}
else
{
// something went wrong...
}
}
catch (Geom::InfiniteSolutions const &e) {
// the parallel_hull_edge and prev_parallel_hull_edge lie on top of each other, hence infinite crossings
g_message("conn-avoid-ref.cpp: trying to get crossings of identical lines");
}
}
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 :