From: Jon A. Cruz Date: Sun, 20 Dec 2009 09:40:55 +0000 (-0800) Subject: Warning cleanup X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=cc618cb0faf84b6f5ab2cc9802b29d03f6a22f97;p=inkscape.git Warning cleanup --- diff --git a/src/2geom/path-intersection.cpp b/src/2geom/path-intersection.cpp index f883f8c63..2e4eba519 100644 --- a/src/2geom/path-intersection.cpp +++ b/src/2geom/path-intersection.cpp @@ -41,16 +41,16 @@ int winding(Path const &path, Point p) { starting = false; Rect bounds = *(iter->boundsFast()); Coord x = p[X], y = p[Y]; - + if(x > bounds.right() || !bounds[Y].contains(y)) continue; //ray doesn't intersect box - + Point final = iter->finalPoint(); Point initial = iter->initialPoint(); Cmp final_to_ray = cmp(final[Y], y); Cmp initial_to_ray = cmp(initial[Y], y); - + // if y is included, these will have opposite values, giving order. - Cmp c = cmp(final_to_ray, initial_to_ray); + Cmp c = cmp(final_to_ray, initial_to_ray); if(x < bounds.left()) { // ray goes through bbox // winding delta determined by position of endpoints @@ -100,7 +100,7 @@ int winding(Path const &path, Point p) { //Looks like it looped, which means everything's flat return 0; } - + cont:(void)0; } return wind; @@ -135,10 +135,10 @@ bool path_direction(Path const &p) { } else if(final_to_ray == EQUAL_TO) goto doh; } return res < 0; - + doh: //Otherwise fallback on area - + Piecewise > pw = p.toPwSb(); double area; Point centre; @@ -214,36 +214,34 @@ intersect_polish_f (const gsl_vector * x, void *params, { const double x0 = gsl_vector_get (x, 0); const double x1 = gsl_vector_get (x, 1); - - Geom::Point dx = ((struct rparams *) params)->A(x0) - + + Geom::Point dx = ((struct rparams *) params)->A(x0) - ((struct rparams *) params)->B(x1); - + gsl_vector_set (f, 0, dx[0]); gsl_vector_set (f, 1, dx[1]); - + return GSL_SUCCESS; } #endif -static void +static void intersect_polish_root (Curve const &A, double &s, Curve const &B, double &t) { - int status; - size_t iter = 0; std::vector as, bs; as = A.pointAndDerivatives(s, 2); bs = B.pointAndDerivatives(t, 2); Point F = as[0] - bs[0]; double best = dot(F, F); - + for(int i = 0; i < 4; i++) { - + /** we want to solve J*(x1 - x0) = f(x0) - + |dA(s)[0] -dB(t)[0]| (X1 - X0) = A(s) - B(t) - |dA(s)[1] -dB(t)[1]| + |dA(s)[1] -dB(t)[1]| **/ // We're using the standard transformation matricies, which is numerically rather poor. Much better to solve the equation using elimination. @@ -259,7 +257,7 @@ intersect_polish_root (Curve const &A, double &s, else if (ns>1) ns=1; if (nt<0) nt=0; else if (nt>1) nt=1; - + as = A.pointAndDerivatives(ns, 2); bs = B.pointAndDerivatives(nt, 2); F = as[0] - bs[0]; @@ -277,33 +275,35 @@ intersect_polish_root (Curve const &A, double &s, const size_t n = 2; struct rparams p = {A, B}; gsl_multiroot_function f = {&intersect_polish_f, n, &p}; - + double x_init[2] = {s, t}; gsl_vector *x = gsl_vector_alloc (n); - + gsl_vector_set (x, 0, x_init[0]); gsl_vector_set (x, 1, x_init[1]); - + const gsl_multiroot_fsolver_type *T = gsl_multiroot_fsolver_hybrids; gsl_multiroot_fsolver *sol = gsl_multiroot_fsolver_alloc (T, 2); gsl_multiroot_fsolver_set (sol, &f, x); - + + int status = 0; + size_t iter = 0; do { iter++; status = gsl_multiroot_fsolver_iterate (sol); - + if (status) /* check if solver is stuck */ break; - + status = gsl_multiroot_test_residual (sol->f, 1e-12); } while (status == GSL_CONTINUE && iter < 1000); - + s = gsl_vector_get (sol->x, 0); t = gsl_vector_get (sol->x, 1); - + gsl_multiroot_fsolver_free (sol); gsl_vector_free (x); } @@ -315,7 +315,7 @@ intersect_polish_root (Curve const &A, double &s, * It passes in the curves, time intervals, and keeps track of depth, while * returning the results through the Crossings parameter. */ -void pair_intersect(Curve const & A, double Al, double Ah, +void pair_intersect(Curve const & A, double Al, double Ah, Curve const & B, double Bl, double Bh, Crossings &ret, unsigned depth = 0) { // std::cout << depth << "(" << Al << ", " << Ah << ")\n"; @@ -324,15 +324,15 @@ void pair_intersect(Curve const & A, double Al, double Ah, OptRect Br = B.boundsLocal(Interval(Bl, Bh)); if (!Br) return; - + if(! Ar->intersects(*Br)) return; - + //Checks the general linearity of the function - if((depth > 12)) { // || (A.boundsLocal(Interval(Al, Ah), 1).maxExtent() < 0.1 + if((depth > 12)) { // || (A.boundsLocal(Interval(Al, Ah), 1).maxExtent() < 0.1 //&& B.boundsLocal(Interval(Bl, Bh), 1).maxExtent() < 0.1)) { double tA, tB, c; - if(linear_intersect(A.pointAt(Al), A.pointAt(Ah), - B.pointAt(Bl), B.pointAt(Bh), + if(linear_intersect(A.pointAt(Al), A.pointAt(Ah), + B.pointAt(Bl), B.pointAt(Bh), tA, tB, c)) { tA = tA * (Ah - Al) + Al; tB = tB * (Bh - Bl) + Bl; @@ -385,8 +385,8 @@ void mono_intersect(Curve const &A, double Al, double Ah, if(depth > 12 || (Ar.maxExtent() < tol && Ar.maxExtent() < tol)) { double tA, tB, c; - if(linear_intersect(A.pointAt(Al), A.pointAt(Ah), - B.pointAt(Bl), B.pointAt(Bh), + if(linear_intersect(A.pointAt(Al), A.pointAt(Ah), + B.pointAt(Bl), B.pointAt(Bh), tA, tB, c)) { tA = tA * (Ah - Al) + Al; tB = tB * (Bh - Bl) + Bl; @@ -483,7 +483,7 @@ std::vector offset_doubles(std::vector const &x, double offs) { std::vector path_mono_splits(Path const &p) { std::vector ret; if(p.empty()) return ret; - + bool pdx=2, pdy=2; //Previous derivative direction for(unsigned i = 0; i < p.size(); i++) { std::vector spl = offset_doubles(curve_mono_splits(p[i]), i); @@ -502,7 +502,7 @@ std::vector path_mono_splits(Path const &p) { } /** - * Applies path_mono_splits to multiple paths, and returns the results such that + * Applies path_mono_splits to multiple paths, and returns the results such that * time-set i corresponds to Path i. */ std::vector > paths_mono_splits(std::vector const &ps) { @@ -541,14 +541,14 @@ CrossingSet MonoCrosser::crossings(std::vector const &a, std::vector if(b.empty()) return CrossingSet(a.size(), Crossings()); CrossingSet results(a.size() + b.size(), Crossings()); if(a.empty()) return results; - + std::vector > splits_a = paths_mono_splits(a), splits_b = paths_mono_splits(b); std::vector > bounds_a = split_bounds(a, splits_a), bounds_b = split_bounds(b, splits_b); - - std::vector bounds_a_union, bounds_b_union; + + std::vector bounds_a_union, bounds_b_union; for(unsigned i = 0; i < bounds_a.size(); i++) bounds_a_union.push_back(union_list(bounds_a[i])); for(unsigned i = 0; i < bounds_b.size(); i++) bounds_b_union.push_back(union_list(bounds_b[i])); - + std::vector > cull = sweep_bounds(bounds_a_union, bounds_b_union); Crossings n; for(unsigned i = 0; i < cull.size(); i++) { @@ -556,7 +556,7 @@ CrossingSet MonoCrosser::crossings(std::vector const &a, std::vector unsigned j = cull[i][jx]; unsigned jc = j + a.size(); Crossings res; - + //Sweep of the monotonic portions std::vector > cull2 = sweep_bounds(bounds_a[i], bounds_b[j]); for(unsigned k = 0; k < cull2.size(); k++) { @@ -567,9 +567,9 @@ CrossingSet MonoCrosser::crossings(std::vector const &a, std::vector res, .1); } } - + for(unsigned k = 0; k < res.size(); k++) { res[k].a = i; res[k].b = jc; } - + merge_crossings(results[i], res, i); merge_crossings(results[i], res, jc); } @@ -583,22 +583,22 @@ CrossingSet MonoCrosser::crossings(std::vector const &a, std::vector CrossingSet crossings_among(std::vector const &p) { CrossingSet results(p.size(), Crossings()); if(p.empty()) return results; - + std::vector > splits = paths_mono_splits(p); std::vector > prs = split_bounds(p, splits); std::vector rs; for(unsigned i = 0; i < prs.size(); i++) rs.push_back(union_list(prs[i])); - + std::vector > cull = sweep_bounds(rs); - + //we actually want to do the self-intersections, so add em in: for(unsigned i = 0; i < cull.size(); i++) cull[i].push_back(i); - + for(unsigned i = 0; i < cull.size(); i++) { for(unsigned jx = 0; jx < cull[i].size(); jx++) { unsigned j = cull[i][jx]; Crossings res; - + //Sweep of the monotonic portions std::vector > cull2 = sweep_bounds(prs[i], prs[j]); for(unsigned k = 0; k < cull2.size(); k++) { @@ -609,14 +609,14 @@ CrossingSet crossings_among(std::vector const &p) { res, .1); } } - + for(unsigned k = 0; k < res.size(); k++) { res[k].a = i; res[k].b = j; } - + merge_crossings(results[i], res, i); merge_crossings(results[j], res, j); } } - + return results; } */ @@ -635,7 +635,7 @@ Crossings curve_self_crossings(Curve const &a) { } /* -void mono_curve_intersect(Curve const & A, double Al, double Ah, +void mono_curve_intersect(Curve const & A, double Al, double Ah, Curve const & B, double Bl, double Bh, Crossings &ret, unsigned depth=0) { // std::cout << depth << "(" << Al << ", " << Ah << ")\n"; @@ -643,9 +643,9 @@ void mono_curve_intersect(Curve const & A, double Al, double Ah, B0 = B.pointAt(Bl), B1 = B.pointAt(Bh); //inline code that this implies? (without rect/interval construction) if(!Rect(A0, A1).intersects(Rect(B0, B1)) || A0 == A1 || B0 == B1) return; - + //Checks the general linearity of the function - if((depth > 12) || (A.boundsLocal(Interval(Al, Ah), 1).maxExtent() < 0.1 + if((depth > 12) || (A.boundsLocal(Interval(Al, Ah), 1).maxExtent() < 0.1 && B.boundsLocal(Interval(Bl, Bh), 1).maxExtent() < 0.1)) { double tA, tB, c; if(linear_intersect(A0, A1, B0, B1, tA, tB, c)) { @@ -705,7 +705,7 @@ Crossings path_self_crossings(Path const &p) { for(unsigned jx = 0; jx < cull[i].size(); jx++) { unsigned j = cull[i][jx]; res.clear(); - + std::vector > cull2 = sweep_bounds(bnds[i], bnds[j]); for(unsigned k = 0; k < cull2.size(); k++) { for(unsigned lx = 0; lx < cull2[k].size(); lx++) { @@ -713,7 +713,7 @@ Crossings path_self_crossings(Path const &p) { mono_curve_intersect(p[i], spl[i][k-1], spl[i][k], p[j], spl[j][l-1], spl[j][l], res); } } - + //if(fabs(int(i)-j) == 1 || fabs(int(i)-j) == p.size()-1) { Crossings res2; for(unsigned k = 0; k < res.size(); k++) { @@ -742,7 +742,7 @@ Crossings self_crossings(Path const &p) { unsigned j = cull[i][jx]; res.clear(); pair_intersect(p[i], 0, 1, p[j], 0, 1, res); - + //if(fabs(int(i)-j) == 1 || fabs(int(i)-j) == p.size()-1) { Crossings res2; for(unsigned k = 0; k < res.size(); k++) { @@ -767,9 +767,9 @@ void flip_crossings(Crossings &crs) { CrossingSet crossings_among(std::vector const &p) { CrossingSet results(p.size(), Crossings()); if(p.empty()) return results; - + SimpleCrosser cc; - + std::vector > cull = sweep_bounds(bounds(p)); for(unsigned i = 0; i < cull.size(); i++) { Crossings res = self_crossings(p[i]); @@ -779,7 +779,7 @@ CrossingSet crossings_among(std::vector const &p) { merge_crossings(results[i], res, i); for(unsigned jx = 0; jx < cull[i].size(); jx++) { unsigned j = cull[i][jx]; - + Crossings res = cc.crossings(p[i], p[j]); for(unsigned k = 0; k < res.size(); k++) { res[k].a = i; res[k].b = j; } merge_crossings(results[i], res, i); diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index c04ad9e49..b9dc218b4 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -56,7 +56,7 @@ SPAvoidRef::~SPAvoidRef() { _transformed_connection.disconnect(); - // If the document is being destroyed then the router instance + // If the document is being destroyed then the router instance // and the ShapeRefs will have been destroyed with it. const bool routerInstanceExists = (item->document->router != NULL); @@ -103,10 +103,10 @@ void SPAvoidRef::setConnectionPoints(gchar const *value) Update the connectors for which the endpoint has changed. */ - + gchar ** strarray = g_strsplit(value, "|", 0); gchar ** iter = strarray; - + while (*iter != NULL) { ConnectionPoint cp; Inkscape::SVGIStringStream is(*iter); @@ -167,17 +167,19 @@ void SPAvoidRef::setConnectionPoints(gchar const *value) { SPPath* path = SP_PATH(i->data); SPConnEnd** connEnds = path->connEndPair.getConnEnds(); - for (int ix=0; ix<2; ++ix) - if (connEnds[ix]->type == ConnPointUserDefined) - if (updates.find(connEnds[ix]->id) != updates.end()) - if (path->connEndPair.isAutoRoutingConn()) + for (int ix=0; ix<2; ++ix) { + if (connEnds[ix]->type == ConnPointUserDefined) { + if (updates.find(connEnds[ix]->id) != updates.end()) { + if (path->connEndPair.isAutoRoutingConn()) { path->connEndPair.tellLibavoidNewEndpoints(); - else - { + } else { } - else - if (deletes.find(connEnds[ix]->id) != deletes.end()) - sp_conn_end_detach(path, ix); + } + else if (deletes.find(connEnds[ix]->id) != deletes.end()) { + sp_conn_end_detach(path, ix); + } + } + } } g_slist_free(conns); // Remove all deleted connection points @@ -189,7 +191,7 @@ void SPAvoidRef::setConnectionPoints(gchar const *value) void SPAvoidRef::setConnectionPointsAttrUndoable(const gchar* value, const gchar* action) { SPDocument* doc = SP_OBJECT_DOCUMENT(item); - + sp_object_setAttribute( SP_OBJECT(item), "inkscape:connection-points", value, 0 ); item->updateRepr(); sp_document_ensure_up_to_date(doc); @@ -229,7 +231,7 @@ void SPAvoidRef::addConnectionPoint(ConnectionPoint &cp) } else ostr<<'|'<setConnectionPointsAttrUndoable( ostr.str().c_str(), _("Added a new connection point") ); } @@ -263,19 +265,17 @@ void SPAvoidRef::deleteConnectionPoint(ConnectionPoint &cp) { Inkscape::SVGOStringStream ostr; IdConnectionPointMap::iterator cp_pos = connection_points.find( cp.id ); - if ( cp_pos != connection_points.end() ) - { + if ( cp_pos != connection_points.end() ) { bool first = true; - for (IdConnectionPointMap::iterator it = connection_points.begin(); it != connection_points.end(); ++it) - { - if ( it != cp_pos ) - if ( first ) - { + for (IdConnectionPointMap::iterator it = connection_points.begin(); it != connection_points.end(); ++it) { + if ( it != cp_pos ) { + if ( first ) { first = false; ostr<second; - } - else + } else { ostr<<'|'<second; + } + } } this->setConnectionPointsAttrUndoable( ostr.str().c_str(), _("Removed a connection point") ); } @@ -304,7 +304,7 @@ void SPAvoidRef::handleSettingChange(void) setting = new_setting; Router *router = item->document->router; - + _transformed_connection.disconnect(); if (new_setting) { Avoid::Polygon poly = avoid_item_poly(item); @@ -314,19 +314,19 @@ void SPAvoidRef::handleSettingChange(void) const char *id = SP_OBJECT_REPR(item)->attribute("id"); g_assert(id != NULL); - + // Get a unique ID for the item. GQuark itemID = g_quark_from_string(id); shapeRef = new Avoid::ShapeRef(router, poly, itemID); - + router->addShape(shapeRef); } } else { g_assert(shapeRef); - + router->removeShape(shapeRef); delete shapeRef; shapeRef = NULL; @@ -341,7 +341,7 @@ GSList *SPAvoidRef::getAttachedShapes(const unsigned int type) Avoid::IntList shapes; GQuark shapeId = g_quark_from_string(item->id); item->document->router->attachedShapes(shapes, shapeId, type); - + Avoid::IntList::iterator finish = shapes.end(); for (Avoid::IntList::iterator i = shapes.begin(); i != finish; ++i) { const gchar *connId = g_quark_to_string(*i); @@ -365,7 +365,7 @@ GSList *SPAvoidRef::getAttachedConnectors(const unsigned int type) Avoid::IntList conns; GQuark shapeId = g_quark_from_string(item->id); item->document->router->attachedConns(conns, shapeId, type); - + Avoid::IntList::iterator finish = conns.end(); for (Avoid::IntList::iterator i = conns.begin(); i != finish; ++i) { const gchar *connId = g_quark_to_string(*i); @@ -386,6 +386,7 @@ Geom::Point SPAvoidRef::getConnectionPointPos(const int type, const int id) g_assert(item); Geom::Point pos; const Geom::Matrix& transform = sp_item_i2doc_affine(item); + // TODO investigate why this was asking for the active desktop: SPDesktop *desktop = inkscape_active_desktop(); if ( type == ConnPointDefault ) @@ -419,7 +420,7 @@ bool SPAvoidRef::isValidConnPointId( const int type, const int id ) else return connection_points.find( id ) != connection_points.end(); } - + return true; } @@ -445,7 +446,7 @@ static Avoid::Polygon avoid_item_poly(SPItem const *item) if ( convex_hull_approximation_enabled && SP_IS_SHAPE (item) ) { // The number of points to use for approximation - const unsigned NUM_POINTS = 64; + const unsigned NUM_POINTS = 64; // printf("[sommer] is a shape\n"); SPCurve* curve = sp_shape_get_curve (SP_SHAPE (item)); @@ -460,7 +461,7 @@ static Avoid::Polygon avoid_item_poly(SPItem const *item) const Geom::PathVector& curve_pv = curve->get_pathvector(); std::vector hull_points; for (Geom::PathVector::const_iterator i = curve_pv.begin(); i != curve_pv.end(); i++) { - const Geom::Path& curve_pv_path = *i; + const Geom::Path& curve_pv_path = *i; // printf("[sommer] tracing sub-path\n"); // FIXME: enlarge path by "desktop->namedview->connector_spacing" (using sp_selected_path_do_offset)? @@ -472,7 +473,7 @@ static Avoid::Polygon avoid_item_poly(SPItem const *item) // sample points along the path for approximation of convex hull for (unsigned n = 0; n < num_points; n++) { - double at = curve_pv_path.size() / static_cast(num_points) * n; + double at = curve_pv_path.size() / static_cast(num_points) * n; Geom::Point pt = curve_pv_path.pointAt(at); hull_points.push_back(pt); } @@ -486,7 +487,9 @@ static Avoid::Polygon avoid_item_poly(SPItem const *item) // store expanded convex hull in Avoid::Polygn unsigned n = 0; Avoid::Polygon poly; +/* const Geom::Point& old_pt = *hull.boundary.begin(); +*/ Geom::Line hull_edge(*hull.boundary.begin(), *(hull.boundary.begin()+1)); Geom::Line parallel_hull_edge; @@ -498,15 +501,17 @@ static Avoid::Polygon avoid_item_poly(SPItem const *item) if (int_pt) { - Avoid::Point avoid_pt((parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X], + Avoid::Point avoid_pt((parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X], (parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::Y]); // printf("[sommer] %f, %f\n", old_pt[Geom::X], old_pt[Geom::Y]); -/* printf("[sommer] %f, %f\n", (parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X], +/* printf("[sommer] %f, %f\n", (parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X], (parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::Y]);*/ poly.ps.push_back(avoid_pt); } for (std::vector::const_iterator i = hull.boundary.begin() + 1; i != hull.boundary.end(); i++, n++) { +/* const Geom::Point& old_pt = *i; +*/ Geom::Line hull_edge(*i, *(i+1)); Geom::Line parallel_hull_edge; parallel_hull_edge.origin(hull_edge.origin()+hull_edge.versor().ccw()*spacing); @@ -516,21 +521,21 @@ static Avoid::Polygon avoid_item_poly(SPItem const *item) if (int_pt) { - Avoid::Point avoid_pt((parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X], + Avoid::Point avoid_pt((parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X], (parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::Y]); /* printf("[sommer] %f, %f\n", old_pt[Geom::X], old_pt[Geom::Y]); - printf("[sommer] %f, %f\n", (parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X], + printf("[sommer] %f, %f\n", (parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X], (parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::Y]);*/ poly.ps.push_back(avoid_pt); } } - + return poly; }// else printf("[sommer] is no curve\n"); }// else printf("[sommer] is no shape\n"); } - + Geom::OptRect rHull = item->getBounds(sp_item_i2doc_affine(item)); if (!rHull) { return Avoid::Polygon(); @@ -538,7 +543,7 @@ static Avoid::Polygon avoid_item_poly(SPItem const *item) // Add a little buffer around the edge of each object. Geom::Rect rExpandedHull = *rHull; - rExpandedHull.expandBy(spacing); + rExpandedHull.expandBy(spacing); Avoid::Polygon poly(4); for (size_t n = 0; n < 4; ++n) { @@ -551,14 +556,14 @@ static Avoid::Polygon avoid_item_poly(SPItem const *item) } -GSList *get_avoided_items(GSList *list, SPObject *from, SPDesktop *desktop, +GSList *get_avoided_items(GSList *list, SPObject *from, SPDesktop *desktop, bool initialised) { for (SPObject *child = sp_object_first_child(SP_OBJECT(from)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_ITEM(child) && !desktop->isLayer(SP_ITEM(child)) && - !SP_ITEM(child)->isLocked() && + !SP_ITEM(child)->isLocked() && !desktop->itemIsHidden(SP_ITEM(child)) && (!initialised || SP_ITEM(child)->avoidRef->shapeRef) ) @@ -595,7 +600,7 @@ void init_avoided_shape_geometry(SPDesktop *desktop) SPDocument *document = sp_desktop_document(desktop); bool saved = sp_document_get_undo_sensitive(document); sp_document_set_undo_sensitive(document, false); - + bool initialised = false; GSList *items = get_avoided_items(NULL, desktop->currentRoot(), desktop, initialised); diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 228c81d29..307d59d1f 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -35,7 +35,7 @@ * Gobbling away all duplicates after the current can occasionally result * in the path lagging behind the mouse cursor if it is no longer being * dragged. - * o Fix up libavoid's representation after undo actions. It doesn't see + * o Fix up libavoid's representation after undo actions. It doesn't see * any transform signals and hence doesn't know shapes have moved back to * there earlier positions. * o Decide whether drawing/editing mode should be an Inkscape preference @@ -46,83 +46,83 @@ * ---------------------------------------------------------------------------- * * mjwybrow's observations on acracan's Summer of Code connector work: - * + * * - GUI comments: - * + * * - Buttons for adding and removing user-specified connection * points should probably have "+" and "-" symbols on them so they * are consistent with the similar buttons for the node tool. - * - Controls on the connector tool be should be reordered logically, + * - Controls on the connector tool be should be reordered logically, * possibly as follows: - * - * *Connector*: [Polyline-radio-button] [Orthgonal-radio-button] + * + * *Connector*: [Polyline-radio-button] [Orthgonal-radio-button] * [Curvature-control] | *Shape*: [Avoid-button] [Dont-avoid-button] * [Spacing-control] | *Connection pts*: [Edit-mode] [Add-pt] [Rm-pt] - * - * I think that the network layout controls be moved to the - * Align and Distribute dialog (there is already the layout button + * + * I think that the network layout controls be moved to the + * Align and Distribute dialog (there is already the layout button * there, but no options are exposed). - * + * * I think that the style change between polyline and orthogonal * would be much clearer with two buttons (radio behaviour -- just * one is true). - * - * The other tools show a label change from "New:" to "Change:" + * + * The other tools show a label change from "New:" to "Change:" * depending on whether an object is selected. We could consider * this but there may not be space. - * + * * The Add-pt and Rm-pt buttons should be greyed out (inactive) if * we are not in connection point editing mode. And probably also * if there is no shape selected, i.e. at the times they have no * effect when clicked. - * - * Likewise for the avoid/ignore shapes buttons. These should be + * + * Likewise for the avoid/ignore shapes buttons. These should be * inactive when a shape is not selected in the connector context. - * + * * - When creating/editing connection points: - * + * * - Strange things can happen if you have connectors selected, or - * try rerouting connectors by dragging their endpoints when in + * try rerouting connectors by dragging their endpoints when in * connection point editing mode. - * + * * - Possibly the selected shape's connection points should always * be shown (i.e., have knots) when in editing mode. - * + * * - It is a little strange to be able to place connection points * competely outside shapes. Especially when you later can't draw * connectors to them since the knots are only visible when you * are over the shape. I think that you should only be able to - * place connection points inside or on the boundary of the shape + * place connection points inside or on the boundary of the shape * itself. - * - * - The intended ability to place a new point at the current cursor + * + * - The intended ability to place a new point at the current cursor * position by pressing RETURN does not seem to work. - * + * * - The Status bar tooltip should change to reflect editing mode * and tell the user about RETURN and how to use the tool. - * + * * - Connection points general: - * - * - Connection points that were inside the shape can end up outside + * + * - Connection points that were inside the shape can end up outside * after a rotation is applied to the shape in the select tool. * It doesn't seem like the correct transform is being applied to * these, or it is being applied at the wrong time. I'd expect * connection points to rotate with the shape, and stay at the * same position "on the shape" - * + * * - I was able to make the connectors attached to a shape fall off * the shape after scaling it. Not sure the exact cause, but may * require more investigation/debugging. - * + * * - The user-defined connection points should be either absolute * (as the current ones are) or defined as a percentage of the * shape. These would be based on a toggle setting on the * toolbar, and they would be placed in exactly the same way by * the user. The only difference would be that they would be * store as percentage positions in the SVG connection-points - * property and that they would update/move automatically if the + * property and that they would update/move automatically if the * object was resized or scaled. - * + * * - Thinking more, I think you always want to store and think about * the positions of connection points to be pre-transform, but * obviously the shape transform is applied to them. That way, @@ -130,14 +130,14 @@ * the shape transform is altered. The Percentage version would * compute their position from the pre-transform dimensions and * then have the transform applied to them, for example. - * + * * - The connection points in the test_connection_points.svg file * seem to follow the shape when it is moved, but connection * points I add to new shapes, do not follow the shape, either * when the shape is just moved or transformed. There is - * something wrong here. What exactly should the behaviour be + * something wrong here. What exactly should the behaviour be * currently? - * + * * - I see that connection points are specified at absolute canvas * positions. I really think that they should be specified in * shape coordinated relative to the shapes. There may be @@ -333,7 +333,7 @@ sp_connector_context_init(SPConnectorContext *cc) cc->clickedhandle = NULL; new (&cc->connpthandles) ConnectionPointMap(); - + for (int i = 0; i < 2; ++i) { cc->endpt_handle[i] = NULL; cc->endpt_handler_id[i] = 0; @@ -353,7 +353,7 @@ sp_connector_context_dispose(GObject *object) cc->sel_changed_connection.disconnect(); if (!cc->connpthandles.empty()) { - for (ConnectionPointMap::iterator it = cc->connpthandles.begin(); + for (ConnectionPointMap::iterator it = cc->connpthandles.begin(); it != cc->connpthandles.end(); ++it) { g_object_unref(it->first); } @@ -413,7 +413,7 @@ sp_connector_context_setup(SPEventContext *ec) cc_selection_changed(cc->selection, (gpointer) cc); cc->within_tolerance = false; - + sp_event_context_read(ec, "curvature"); sp_event_context_read(ec, "orthogonal"); sp_event_context_read(ec, "mode"); @@ -472,7 +472,7 @@ void sp_connector_context_switch_mode(SPEventContext* ec, unsigned int newMode) { cc->selection->set( SP_OBJECT( cc->active_shape ) ); } - else + else { SPItem* item = cc->selection->singleItem(); if ( item ) @@ -537,7 +537,7 @@ cc_clear_active_shape(SPConnectorContext *cc) // Hide the connection points if they exist. if (cc->connpthandles.size()) { - for (ConnectionPointMap::iterator it = cc->connpthandles.begin(); + for (ConnectionPointMap::iterator it = cc->connpthandles.begin(); it != cc->connpthandles.end(); ++it) { sp_knot_hide(it->first); } @@ -616,7 +616,7 @@ sp_connector_context_item_handler(SPEventContext *event_context, SPItem *item, G SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(event_context); Geom::Point p(event->button.x, event->button.y); - + switch (event->type) { case GDK_BUTTON_RELEASE: if (event->button.button == 1 && !event_context->space_panning) { @@ -660,11 +660,11 @@ sp_connector_context_item_handler(SPEventContext *event_context, SPItem *item, G if (cc->mode == SP_CONNECTOR_CONTEXT_DRAWING_MODE || (cc->mode == SP_CONNECTOR_CONTEXT_EDITING_MODE && !cc->selected_handle)) { if (cc_item_is_shape(item)) { - + // I don't really understand what the above does, // so I commented it. // This is a shape, so show connection point(s). - /* if (!(cc->active_shape) + /* if (!(cc->active_shape) // Don't show handle for another handle. // || (cc->connpthandles.find((SPKnot*) item) != cc->connpthandles.end()) ) @@ -847,7 +847,7 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const cc->xp = bevent.x; cc->yp = bevent.y; cc->within_tolerance = true; - + ConnectionPointMap::iterator const& active_knot_it = cc->connpthandles.find( cc->active_handle ); switch (cc->state) @@ -934,7 +934,7 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons { SnapManager &m = dt->namedview->snap_manager; m.setup(dt); - + switch (cc->state) { case SP_CONNECTOR_CONTEXT_DRAGGING: { @@ -1074,7 +1074,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con switch ( cc->state ) { case SP_CONNECTOR_CONTEXT_DRAGGING: - + if (!cc->within_tolerance) { // sp_event_context_snap_window_open(event_context); @@ -1094,7 +1094,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con case SP_CONNECTOR_CONTEXT_NEWCONNPOINT: // sp_event_context_snap_window_open( event_context ); m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE); - + sp_knot_set_position(cc->selected_handle, p, 0); // sp_event_context_snap_window_closed(event_context); @@ -1118,7 +1118,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con } } } - + return ret; } @@ -1196,8 +1196,8 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop); Geom::Point p = cc->selected_handle->pos; - SPEventContext* event_context = SP_EVENT_CONTEXT( cc ); - +// SPEventContext* event_context = SP_EVENT_CONTEXT( cc ); + if (!cc->within_tolerance) { // sp_event_context_snap_window_open(event_context); @@ -1229,11 +1229,11 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop); Geom::Point p = cc->selected_handle->pos; - SPEventContext* event_context = SP_EVENT_CONTEXT( cc ); - +// SPEventContext* event_context = SP_EVENT_CONTEXT( cc ); + // sp_event_context_snap_window_open( event_context ); m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE); - + sp_knot_set_position(cc->selected_handle, p, 0); // sp_event_context_snap_window_closed(event_context); @@ -1263,7 +1263,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) cc->selected_handle = NULL; ret = TRUE; } - + break; } } @@ -1453,7 +1453,7 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc) // Process pending updates. cc->newconn->updateRepr(); sp_document_ensure_up_to_date(doc); - + if (connection) { // Adjust endpoints to shape edge. sp_conn_reroute_path_immediate(SP_PATH(cc->newconn)); @@ -1461,7 +1461,7 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc) } // Only set the selection after we are finished with creating the attributes of - // the connector. Otherwise, the selection change may alter the defaults for + // the connector. Otherwise, the selection change may alter the defaults for // values like curvature in the connector context, preventing subsequent lookup // of their original values. cc->selection->set(repr); @@ -1630,7 +1630,7 @@ static void cc_active_shape_add_knot(SPDesktop* desktop, SPItem* item, Connectio static void cc_set_active_shape(SPConnectorContext *cc, SPItem *item) { g_assert(item != NULL ); - + std::map* connpts = &item->avoidRef->connection_points; if (cc->active_shape != item) @@ -1671,7 +1671,7 @@ static void cc_set_active_shape(SPConnectorContext *cc, SPItem *item) if ( connpts->size() ) for (std::map::iterator it = connpts->begin(); it != connpts->end(); ++it) cc_active_shape_add_knot(cc->desktop, item, cc->connpthandles, it->second); - + // Also add default connection points // For now, only centre default connection point will // be available diff --git a/src/display/nr-filter-convolve-matrix.cpp b/src/display/nr-filter-convolve-matrix.cpp index 05d38701f..fc88102d8 100644 --- a/src/display/nr-filter-convolve-matrix.cpp +++ b/src/display/nr-filter-convolve-matrix.cpp @@ -41,7 +41,7 @@ static inline void convolve2D_XY(unsigned int const x, unsigned int const y, uns unsigned int jEnd = X_UPPER ? width+targetX-x : orderX; for (unsigned int i=iBegin; iname ; entry++, ret++) - if (ch >= entry->low && ch <= entry->high) + int ret = 0; + for (UcdBlockData *entry = ucd_blocks; entry->name ; entry++, ret++) { + if ((ch >= entry->low) && (ch <= entry->high)) { return ret; + } + } return UCD_BLOCK_NO_BLOCK; } diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index 95adbce0e..5415fdc80 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -145,9 +145,11 @@ static void sp_dropper_context_finish(SPEventContext *ec) /** * Returns the current dropper context icc-color. */ -SPColor* sp_dropper_context_get_icc_color(SPEventContext *ec) +SPColor* sp_dropper_context_get_icc_color(SPEventContext */*ec*/) { //TODO: implement-me! + + return 0; // At least we will cause a clean crash, instead of random corruption. } /** diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp index 9ac19326f..737bb2885 100644 --- a/src/extension/internal/cairo-ps-out.cpp +++ b/src/extension/internal/cairo-ps-out.cpp @@ -42,22 +42,22 @@ namespace Inkscape { namespace Extension { namespace Internal { -bool -CairoPsOutput::check (Inkscape::Extension::Extension * module) +bool CairoPsOutput::check (Inkscape::Extension::Extension * /*module*/) { - if (NULL == Inkscape::Extension::db.get(SP_MODULE_KEY_PRINT_CAIRO_PS)) - return FALSE; - - return TRUE; + if (NULL == Inkscape::Extension::db.get(SP_MODULE_KEY_PRINT_CAIRO_PS)) { + return FALSE; + } else { + return TRUE; + } } -bool -CairoEpsOutput::check (Inkscape::Extension::Extension * module) +bool CairoEpsOutput::check (Inkscape::Extension::Extension * /*module*/) { - if (NULL == Inkscape::Extension::db.get(SP_MODULE_KEY_PRINT_CAIRO_EPS)) - return FALSE; - - return TRUE; + if (NULL == Inkscape::Extension::db.get(SP_MODULE_KEY_PRINT_CAIRO_EPS)) { + return FALSE; + } else { + return TRUE; + } } static bool diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h index e6f2d698e..a1f902457 100644 --- a/src/extension/internal/cairo-render-context.h +++ b/src/extension/internal/cairo-render-context.h @@ -71,12 +71,12 @@ public: CairoRenderer *getRenderer(void) const; cairo_t *getCairoContext(void) const; - typedef enum CairoRenderMode { + enum CairoRenderMode { RENDER_MODE_NORMAL, RENDER_MODE_CLIP }; - typedef enum CairoClipMode { + enum CairoClipMode { CLIP_MODE_PATH, CLIP_MODE_MASK }; diff --git a/src/filters/image.cpp b/src/filters/image.cpp index ad516a84e..eb6dfc22a 100644 --- a/src/filters/image.cpp +++ b/src/filters/image.cpp @@ -43,8 +43,7 @@ static void sp_feImage_build_renderer(SPFilterPrimitive *primitive, Inkscape::Fi static SPFilterPrimitiveClass *feImage_parent_class; -GType -sp_feImage_get_type() +GType sp_feImage_get_type() { static GType feImage_type = 0; @@ -64,8 +63,7 @@ sp_feImage_get_type() return feImage_type; } -static void -sp_feImage_class_init(SPFeImageClass *klass) +static void sp_feImage_class_init(SPFeImageClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *)klass; SPFilterPrimitiveClass * sp_primitive_class = (SPFilterPrimitiveClass *)klass; @@ -81,8 +79,7 @@ sp_feImage_class_init(SPFeImageClass *klass) sp_primitive_class->build_renderer = sp_feImage_build_renderer; } -static void -sp_feImage_init(SPFeImage */*feImage*/) +static void sp_feImage_init(SPFeImage */*feImage*/) { } @@ -91,8 +88,7 @@ sp_feImage_init(SPFeImage */*feImage*/) * our name must be associated with a repr via "sp_object_type_register". Best done through * sp-object-repr.cpp's repr_name_entries array. */ -static void -sp_feImage_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +static void sp_feImage_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { // Save document reference so we can load images with relative paths. SPFeImage *feImage = SP_FEIMAGE(object); @@ -115,8 +111,7 @@ sp_feImage_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *re /** * Drops any allocated memory. */ -static void -sp_feImage_release(SPObject *object) +static void sp_feImage_release(SPObject *object) { SPFeImage *feImage = SP_FEIMAGE(object); feImage->_image_modified_connection.disconnect(); @@ -127,14 +122,12 @@ sp_feImage_release(SPObject *object) ((SPObjectClass *) feImage_parent_class)->release(object); } -static void -sp_feImage_elem_modified(SPObject* /*href*/, guint /*flags*/, SPObject* obj) +static void sp_feImage_elem_modified(SPObject* /*href*/, guint /*flags*/, SPObject* obj) { obj->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); } -static void -sp_feImage_href_modified(SPObject* old_elem, SPObject* new_elem, SPObject* obj) +static void sp_feImage_href_modified(SPObject* /*old_elem*/, SPObject* new_elem, SPObject* obj) { SPFeImage *feImage = SP_FEIMAGE(obj); feImage->_image_modified_connection.disconnect(); @@ -151,8 +144,7 @@ sp_feImage_href_modified(SPObject* old_elem, SPObject* new_elem, SPObject* obj) /** * Sets a specific value in the SPFeImage. */ -static void -sp_feImage_set(SPObject *object, unsigned int key, gchar const *value) +static void sp_feImage_set(SPObject *object, unsigned int key, gchar const *value) { SPFeImage *feImage = SP_FEIMAGE(object); (void)feImage; @@ -221,8 +213,7 @@ sp_feImage_set(SPObject *object, unsigned int key, gchar const *value) /** * Receives update notifications. */ -static void -sp_feImage_update(SPObject *object, SPCtx *ctx, guint flags) +static void sp_feImage_update(SPObject *object, SPCtx *ctx, guint flags) { if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | @@ -239,8 +230,7 @@ sp_feImage_update(SPObject *object, SPCtx *ctx, guint flags) /** * Writes its settings to an incoming repr object, if any. */ -static Inkscape::XML::Node * -sp_feImage_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) +static Inkscape::XML::Node * sp_feImage_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { /* TODO: Don't just clone, but create a new repr node and write all * relevant values into it */ diff --git a/src/libavoid/connector.cpp b/src/libavoid/connector.cpp index d9088dfe7..3dbd941a4 100644 --- a/src/libavoid/connector.cpp +++ b/src/libavoid/connector.cpp @@ -586,7 +586,7 @@ Router *ConnRef::router(void) const } -bool ConnRef::generatePath(Point p0, Point p1) +bool ConnRef::generatePath(Point /*p0*/, Point /*p1*/) { // XXX Code to determine when connectors really need to be rerouted // does not yet work for orthogonal connectors. diff --git a/src/libavoid/orthogonal.cpp b/src/libavoid/orthogonal.cpp index 747fd1f86..4a7b0af2d 100644 --- a/src/libavoid/orthogonal.cpp +++ b/src/libavoid/orthogonal.cpp @@ -12,12 +12,12 @@ * 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 + * 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * Author(s): Michael Wybrow */ @@ -52,11 +52,11 @@ static const size_t XDIM = 0; static const size_t YDIM = 1; -class ShiftSegment +class ShiftSegment { public: // For shiftable segments. - ShiftSegment(ConnRef *conn, const size_t low, const size_t high, + ShiftSegment(ConnRef *conn, const size_t low, const size_t high, bool isSBend, const size_t dim, double minLim, double maxLim) : connRef(conn), indexLow(low), @@ -69,8 +69,9 @@ class ShiftSegment maxSpaceLimit(maxLim) { } + // For fixed segments. - ShiftSegment(ConnRef *conn, const size_t low, const size_t high, + ShiftSegment(ConnRef *conn, const size_t low, const size_t high, const size_t dim) : connRef(conn), indexLow(low), @@ -84,23 +85,28 @@ class ShiftSegment minSpaceLimit = lowPoint()[dim]; maxSpaceLimit = lowPoint()[dim]; } + Point& lowPoint(void) { return connRef->displayRoute().ps[indexLow]; } + Point& highPoint(void) { return connRef->displayRoute().ps[indexHigh]; } + const Point& lowPoint(void) const { return connRef->displayRoute().ps[indexLow]; } - const Point& highPoint(void) const + + const Point& highPoint(void) const { return connRef->displayRoute().ps[indexHigh]; } - const int fixedOrder(bool& isFixed) const + + int fixedOrder(bool& isFixed) const { if (fixed) { @@ -117,7 +123,8 @@ class ShiftSegment } return 0; } - const int order(void) const + + int order(void) const { if (lowC()) { @@ -129,17 +136,19 @@ class ShiftSegment } return 0; } + bool operator<(const ShiftSegment& rhs) const { const Point& lowPt = lowPoint(); const Point& rhsLowPt = rhs.lowPoint(); - + if (lowPt[dimension] != rhsLowPt[dimension]) { return lowPt[dimension] < rhsLowPt[dimension]; } return this < &rhs; } + // This counts segments that are colliear and share an endpoint as // overlapping. This allows them to be nudged apart where possible. bool overlapsWith(const ShiftSegment& rhs, const size_t dim) const @@ -171,7 +180,7 @@ class ShiftSegment double minSpaceLimit; double maxSpaceLimit; private: - const bool lowC(void) const + bool lowC(void) const { // This is true if this is a cBend and its adjoining points // are at lower positions. @@ -181,7 +190,8 @@ class ShiftSegment } return false; } - const bool highC(void) const + + bool highC(void) const { // This is true if this is a cBend and its adjoining points // are at higher positions. @@ -204,7 +214,7 @@ struct Node; struct CmpNodePos { bool operator()(const Node* u, const Node* v) const; }; typedef std::set NodeSet; -struct Node +struct Node { ShapeRef *v; VertInf *c; @@ -221,10 +231,10 @@ struct Node pos(p), firstAbove(NULL), firstBelow(NULL) - { + { //COLA_ASSERT(r->width()<1e40); v->polygon().getBoundingRect(&min[0], &min[1], &max[0], &max[1]); - } + } Node(VertInf *c, const double p) : v(NULL), c(c), @@ -235,7 +245,7 @@ struct Node { min[0] = max[0] = c->point.x; min[1] = max[1] = c->point.y; - } + } Node(ShiftSegment *ss, const double p) : v(NULL), c(NULL), @@ -246,8 +256,8 @@ struct Node { // These values shouldn't ever be used, so they don't matter. min[0] = max[0] = min[1] = max[1] = 0; - } - ~Node() + } + ~Node() { } // Find the first Node above in the scanline that is a shape edge, @@ -260,7 +270,7 @@ struct Node { curr = curr->firstAbove; } - + if (curr) { return curr->max[dim]; @@ -277,14 +287,14 @@ struct Node { curr = curr->firstBelow; } - + if (curr) { return curr->min[dim]; } return DBL_MAX; } - // Mark all connector segments above in the scanline as being able + // Mark all connector segments above in the scanline as being able // to see to this shape edge. void markShiftSegmentsAbove(size_t dim) { @@ -293,13 +303,13 @@ struct Node { if (curr->ss && (curr->pos <= min[dim])) { - curr->ss->maxSpaceLimit = + curr->ss->maxSpaceLimit = std::min(min[dim], curr->ss->maxSpaceLimit); } curr = curr->firstAbove; } } - // Mark all connector segments below in the scanline as being able + // Mark all connector segments below in the scanline as being able // to see to this shape edge. void markShiftSegmentsBelow(size_t dim) { @@ -308,7 +318,7 @@ struct Node { if (curr->ss && (curr->pos >= max[dim])) { - curr->ss->minSpaceLimit = + curr->ss->minSpaceLimit = std::max(max[dim], curr->ss->minSpaceLimit); } curr = curr->firstBelow; @@ -320,8 +330,8 @@ struct Node bool clearVisibility = true; firstAbovePos = -DBL_MAX; firstBelowPos = DBL_MAX; - // We start looking left from the right side of the shape, - // and vice versa. + // We start looking left from the right side of the shape, + // and vice versa. lastAbovePos = max[dim]; lastBelowPos = min[dim]; @@ -353,7 +363,7 @@ struct Node } curr = curr->firstAbove; } - + // Find the first blocking edge below this point. Don't count the // edges as we are travelling out of shapes we are inside, but then // mark clearVisibility as false. @@ -385,35 +395,35 @@ struct Node return clearVisibility; } - double firstPointAbove(size_t dim) - { - Node *curr = firstAbove; - while (curr && (curr->max[dim] >= pos)) - { - curr = curr->firstAbove; - } - - if (curr) - { - return curr->max[dim]; - } - return -DBL_MAX; - } - double firstPointBelow(size_t dim) - { - Node *curr = firstBelow; - while (curr && (curr->min[dim] <= pos)) - { - curr = curr->firstBelow; - } - - if (curr) - { - return curr->min[dim]; - } - return DBL_MAX; - } - // This is a bit inefficient, but we won't need to do it once we have + double firstPointAbove(size_t dim) + { + Node *curr = firstAbove; + while (curr && (curr->max[dim] >= pos)) + { + curr = curr->firstAbove; + } + + if (curr) + { + return curr->max[dim]; + } + return -DBL_MAX; + } + double firstPointBelow(size_t dim) + { + Node *curr = firstBelow; + while (curr && (curr->min[dim] <= pos)) + { + curr = curr->firstBelow; + } + + if (curr) + { + return curr->min[dim]; + } + return DBL_MAX; + } + // This is a bit inefficient, but we won't need to do it once we have // connection points. bool isInsideShape(size_t dimension) { @@ -436,17 +446,17 @@ struct Node }; -bool CmpNodePos::operator() (const Node* u, const Node* v) const +bool CmpNodePos::operator() (const Node* u, const Node* v) const { - if (u->pos != v->pos) + if (u->pos != v->pos) { return u->pos < v->pos; } - + // Use the pointers to the base objects to differentiate them. - void *up = (u->v) ? (void *) u->v : + void *up = (u->v) ? (void *) u->v : ((u->c) ? (void *) u->c : (void *) u->ss); - void *vp = (v->v) ? (void *) v->v : + void *vp = (v->v) ? (void *) v->v : ((v->c) ? (void *) v->c : (void *) v->ss); return up < vp; } @@ -456,7 +466,7 @@ bool CmpNodePos::operator() (const Node* u, const Node* v) const typedef enum { Open = 1, SegOpen = 2, - ConnPoint = 3, + ConnPoint = 3, SegClose = 4, Close = 5 } EventType; @@ -464,7 +474,7 @@ typedef enum { struct Event { - Event(EventType t, Node *v, double p) + Event(EventType t, Node *v, double p) : type(t), v(v), pos(p) @@ -496,7 +506,7 @@ int compare_events(const void *a, const void *b) // Returns a bitfield of the direction of visibility (in this dimension) -// made up of ConnDirDown (for visibility towards lower position values) +// made up of ConnDirDown (for visibility towards lower position values) // and ConnDirUp (for visibility towards higher position values). // static ConnDirFlags getPosVertInfDirection(VertInf *v, size_t dim) @@ -526,13 +536,13 @@ static ConnDirFlags getPosVertInfDirection(VertInf *v, size_t dim) } else if (dirs == ConnDirDown) { - // For libavoid the Y-axis points downwards, so in terms of + // For libavoid the Y-axis points downwards, so in terms of // smaller or larger position values, Down is Up and vice versa. return ConnDirUp; } else if (dirs == ConnDirUp) { - // For libavoid the Y-axis points downwards, so in terms of + // For libavoid the Y-axis points downwards, so in terms of // smaller or larger position values, Down is Up and vice versa. return ConnDirDown; } @@ -551,8 +561,8 @@ struct PosVertInf dir(d) { } - - bool operator<(const PosVertInf& rhs) const + + bool operator<(const PosVertInf& rhs) const { if (pos != rhs.pos) { @@ -565,7 +575,7 @@ struct PosVertInf VertInf *vert; // A bitfield marking the direction of visibility (in this dimension) - // made up of ConnDirDown (for visibility towards lower position values) + // made up of ConnDirDown (for visibility towards lower position values) // and ConnDirUp (for visibility towards higher position values). // ConnDirFlags dir; @@ -573,7 +583,7 @@ struct PosVertInf struct CmpVertInf -{ +{ bool operator()(const VertInf* u, const VertInf* v) const { // Comparator for VertSet, an ordered set of VertInf pointers. @@ -596,17 +606,17 @@ struct CmpVertInf typedef std::set VertSet; -// A set of points to break the line segment, +// A set of points to break the line segment, // along with vertices for these points. typedef std::set BreakpointSet; -// Temporary structure used to store the possible horizontal visibility +// Temporary structure used to store the possible horizontal visibility // lines arising from the vertical sweep. -class LineSegment +class LineSegment { public: - LineSegment(const double& b, const double& f, const double& p, - bool ss = false, VertInf *bvi = NULL, VertInf *fvi = NULL) + LineSegment(const double& b, const double& f, const double& p, + bool /*ss*/ = false, VertInf *bvi = NULL, VertInf *fvi = NULL) : begin(b), finish(f), pos(p), @@ -623,6 +633,7 @@ public: vertInfs.insert(fvi); } } + LineSegment(const double& bf, const double& p, VertInf *bfvi = NULL) : begin(bf), finish(bf), @@ -634,9 +645,9 @@ public: vertInfs.insert(bfvi); } } - + // Order by begin, pos, finish. - bool operator<(const LineSegment& rhs) const + bool operator<(const LineSegment& rhs) const { if (begin != rhs.begin) { @@ -662,7 +673,7 @@ public: // Lines are exactly equal. return true; } - + if (pos == rhs.pos) { if (((begin >= rhs.begin) && (begin <= rhs.finish)) || @@ -681,7 +692,7 @@ public: finish = std::max(finish, segment.finish); vertInfs.insert(segment.vertInfs.begin(), segment.vertInfs.end()); } - + VertInf *beginVertInf(void) const { if (vertInfs.empty()) @@ -750,12 +761,12 @@ public: } } - // Converts a section of the points list to a set of breakPoints. + // Converts a section of the points list to a set of breakPoints. // Returns the first of the intersection points occuring at finishPos. - VertSet::iterator addSegmentsUpTo(Router *router, double finishPos) + VertSet::iterator addSegmentsUpTo(Router */*router*/, double finishPos) { VertSet::iterator firstIntersectionPt = vertInfs.end(); - for (VertSet::iterator vert = vertInfs.begin(); + for (VertSet::iterator vert = vertInfs.begin(); vert != vertInfs.end(); ++vert) { if ((*vert)->point.x > finishPos) @@ -763,11 +774,11 @@ public: // We're done. break; } - + breakPoints.insert(PosVertInf((*vert)->point.x, (*vert), getPosVertInfDirection(*vert, XDIM))); - if ((firstIntersectionPt == vertInfs.end()) && + if ((firstIntersectionPt == vertInfs.end()) && ((*vert)->point.x == finishPos)) { firstIntersectionPt = vert; @@ -777,22 +788,22 @@ public: return firstIntersectionPt; } - // Add visibility edge(s) for this segment. There may be multiple if + // Add visibility edge(s) for this segment. There may be multiple if // one of the endpoints is shared by multiple connector endpoints. void addEdgeHorizontal(Router *router) { commitBegin(router); commitFinish(router); - + addSegmentsUpTo(router, finish); } // Add visibility edge(s) for this segment up until an intersection. // Then, move the segment beginning to the intersection point, so we // later only consider the remainder of the segment. - // There may be multiple segments added to the graph if the beginning + // There may be multiple segments added to the graph if the beginning // endpoint of the segment is shared by multiple connector endpoints. - VertSet addEdgeHorizontalTillIntersection(Router *router, + VertSet addEdgeHorizontalTillIntersection(Router *router, LineSegment& vertLine) { VertSet intersectionSet; @@ -801,14 +812,14 @@ public: // Does a vertex already exist for this point. commitPositionX(router, vertLine.pos); - - // Generate segments and set end iterator to the first point + + // Generate segments and set end iterator to the first point // at the intersection position. VertSet::iterator restBegin = addSegmentsUpTo(router, vertLine.pos); // Add the intersections points to intersectionSet. VertSet::iterator restEnd = restBegin; - while ((restEnd != vertInfs.end()) && + while ((restEnd != vertInfs.end()) && (*restEnd)->point.x == vertLine.pos) { ++restEnd; @@ -821,7 +832,7 @@ public: return intersectionSet; } - + // Insert vertical breakpoints. void insertBreakpointsBegin(Router *router, LineSegment& vertLine) { @@ -841,7 +852,7 @@ public: { if ((*v)->point.x == begin) { - vertLine.breakPoints.insert(PosVertInf(pos, *v, + vertLine.breakPoints.insert(PosVertInf(pos, *v, getPosVertInfDirection(*v, YDIM))); } } @@ -911,7 +922,7 @@ public: { // Here we have a pair of two endpoints that are both // connector endpoints and both are inside a shape. - + // Give vert visibility back to the first non-connector // endpoint vertex (i.e., the side of the shape). BreakpointSet::iterator side = last; @@ -926,16 +937,16 @@ public: bool canSeeDown = (vert->dir & ConnDirDown); if (canSeeDown && side->vert->id.isShape) { - EdgeInf *edge = new + EdgeInf *edge = new EdgeInf(side->vert, vert->vert, orthogonal); - edge->setDist(vert->vert->point[dim] - + edge->setDist(vert->vert->point[dim] - side->vert->point[dim]); } // Give last visibility back to the first non-connector // endpoint vertex (i.e., the side of the shape). side = vert; - while ((side != breakPoints.end()) && + while ((side != breakPoints.end()) && !side->vert->id.isShape) { ++side; @@ -943,17 +954,17 @@ public: bool canSeeUp = (last->dir & ConnDirUp); if (canSeeUp && (side != breakPoints.end())) { - EdgeInf *edge = new + EdgeInf *edge = new EdgeInf(last->vert, side->vert, orthogonal); - edge->setDist(side->vert->point[dim] - + edge->setDist(side->vert->point[dim] - last->vert->point[dim]); } } - + // The normal case. // - // Note: It's okay to give two connector endpoints visbility - // here since we only consider the partner endpoint as a + // Note: It's okay to give two connector endpoints visbility + // here since we only consider the partner endpoint as a // candidate while searching if it is the other endpoint of // the connector in question. // @@ -968,9 +979,9 @@ public: } if (generateEdge) { - EdgeInf *edge = + EdgeInf *edge = new EdgeInf(last->vert, vert->vert, orthogonal); - edge->setDist(vert->vert->point[dim] - + edge->setDist(vert->vert->point[dim] - last->vert->point[dim]); } @@ -997,12 +1008,12 @@ public: double finish; double pos; bool shapeSide; - + VertSet vertInfs; BreakpointSet breakPoints; private: - // MSVC wants to generate the assignment operator and the default - // constructor, but fails. Therefore we declare them private and + // MSVC wants to generate the assignment operator and the default + // constructor, but fails. Therefore we declare them private and // don't implement them. LineSegment & operator=(LineSegment const &); LineSegment(); @@ -1032,7 +1043,7 @@ class SegmentListWrapper } else { - // This is the first overlapping segment, so just + // This is the first overlapping segment, so just // merge the new segment with this one. curr->mergeVertInfs(segment); found = curr; @@ -1061,7 +1072,7 @@ class SegmentListWrapper // Given a router instance and a set of possible horizontal segments, and a // possible vertical visibility segment, compute and add edges to the // orthogonal visibility graph for all the visibility edges. -static void intersectSegments(Router *router, SegmentList& segments, +static void intersectSegments(Router *router, SegmentList& segments, LineSegment& vertLine) { COLA_ASSERT(vertLine.beginVertInf() == NULL); @@ -1104,9 +1115,9 @@ static void intersectSegments(Router *router, SegmentList& segments, { // Add horizontal visibility segment. horiLine.addEdgeHorizontal(router); - + horiLine.insertBreakpointsFinish(router, vertLine); - + size_t dim = XDIM; // x-dimension horiLine.generateVisibilityEdgesFromBreakpointSet(router, dim); @@ -1123,7 +1134,7 @@ static void intersectSegments(Router *router, SegmentList& segments, if (inVertSegRegion) { // Add horizontal visibility segment. - VertSet intersectionVerts = + VertSet intersectionVerts = horiLine.addEdgeHorizontalTillIntersection( router, vertLine); @@ -1144,16 +1155,16 @@ static void intersectSegments(Router *router, SegmentList& segments, } -// Processes an event for the vertical sweep used for computing the static -// orthogonal visibility graph. This adds possible visibility sgments to +// Processes an event for the vertical sweep used for computing the static +// orthogonal visibility graph. This adds possible visibility sgments to // the segments list. // The first pass is adding the event to the scanline, the second is for // processing the event and the third for removing it from the scanline. -static void processEventVert(Router *router, NodeSet& scanline, +static void processEventVert(Router *router, NodeSet& scanline, SegmentListWrapper& segments, Event *e, unsigned int pass) { Node *v = e->v; - + if ( ((pass == 1) && (e->type == Open)) || ((pass == 2) && (e->type == ConnPoint)) ) { @@ -1163,21 +1174,21 @@ static void processEventVert(Router *router, NodeSet& scanline, NodeSet::iterator it = v->iter; // Work out neighbours - if (it != scanline.begin()) + if (it != scanline.begin()) { Node *u = *(--it); v->firstAbove = u; u->firstBelow = v; } it = v->iter; - if (++it != scanline.end()) + if (++it != scanline.end()) { Node *u = *it; v->firstBelow = u; u->firstAbove = v; } } - + if (pass == 2) { if ((e->type == Open) || (e->type == Close)) @@ -1198,18 +1209,18 @@ static void processEventVert(Router *router, NodeSet& scanline, if (minLimitMax >= maxLimitMin) { // Insert possible visibility segments. - VertInf *vI1 = new VertInf(router, dummyOrthogID, + VertInf *vI1 = new VertInf(router, dummyOrthogID, Point(minShape, lineY)); - VertInf *vI2 = new VertInf(router, dummyOrthogID, + VertInf *vI2 = new VertInf(router, dummyOrthogID, Point(maxShape, lineY)); - + // There are no overlapping shapes, so give full visibility. if (minLimit < minShape) { segments.insert(LineSegment(minLimit, minShape, lineY, true, NULL, vI1)); } - segments.insert(LineSegment(minShape, maxShape, lineY, + segments.insert(LineSegment(minShape, maxShape, lineY, true, vI1, vI2)); if (maxShape < maxLimit) { @@ -1245,12 +1256,12 @@ static void processEventVert(Router *router, NodeSet& scanline, LineSegment *line1 = NULL, *line2 = NULL; if (!inShape || (centreVert->visDirections & ConnDirLeft)) { - line1 = segments.insert(LineSegment(minLimit, cp.x, e->pos, + line1 = segments.insert(LineSegment(minLimit, cp.x, e->pos, true, NULL, centreVert)); } if (!inShape || (centreVert->visDirections & ConnDirRight)) { - line2 = segments.insert(LineSegment(cp.x, maxLimit, e->pos, + line2 = segments.insert(LineSegment(cp.x, maxLimit, e->pos, true, centreVert, NULL)); } if (!line1 && !line2) @@ -1258,7 +1269,7 @@ static void processEventVert(Router *router, NodeSet& scanline, // Add a point segment for the centre point. segments.insert(LineSegment(cp.x, e->pos, centreVert)); } - + if (!inShape) { // This is not contained within a shape so add a normal @@ -1279,13 +1290,13 @@ static void processEventVert(Router *router, NodeSet& scanline, } } } - + if ( ((pass == 3) && (e->type == Close)) || ((pass == 2) && (e->type == ConnPoint)) ) { // Clean up neighbour pointers. Node *l = v->firstAbove, *r = v->firstBelow; - if (l != NULL) + if (l != NULL) { l->firstBelow = v->firstBelow; } @@ -1310,16 +1321,16 @@ static void processEventVert(Router *router, NodeSet& scanline, } -// Processes an event for the vertical sweep used for computing the static -// orthogonal visibility graph. This adds possible visibility sgments to +// Processes an event for the vertical sweep used for computing the static +// orthogonal visibility graph. This adds possible visibility sgments to // the segments list. // The first pass is adding the event to the scanline, the second is for // processing the event and the third for removing it from the scanline. -static void processEventHori(Router *router, NodeSet& scanline, +static void processEventHori(Router */*router*/, NodeSet& scanline, SegmentListWrapper& segments, Event *e, unsigned int pass) { Node *v = e->v; - + if ( ((pass == 1) && (e->type == Open)) || ((pass == 2) && (e->type == ConnPoint)) ) { @@ -1329,21 +1340,21 @@ static void processEventHori(Router *router, NodeSet& scanline, NodeSet::iterator it = v->iter; // Work out neighbours - if (it != scanline.begin()) + if (it != scanline.begin()) { Node *u = *(--it); v->firstAbove = u; u->firstBelow = v; } it = v->iter; - if (++it != scanline.end()) + if (++it != scanline.end()) { Node *u = *it; v->firstBelow = u; u->firstAbove = v; } } - + if (pass == 2) { if ((e->type == Open) || (e->type == Close)) @@ -1370,13 +1381,13 @@ static void processEventHori(Router *router, NodeSet& scanline, { if ((minLimitMax > minLimit) && (minLimitMax >= minShape)) { - LineSegment vertSeg = + LineSegment vertSeg = LineSegment(minLimit, minLimitMax, lineX); segments.insert(vertSeg); } if ((maxLimitMin < maxLimit) && (maxLimitMin <= maxShape)) { - LineSegment vertSeg = + LineSegment vertSeg = LineSegment(maxLimitMin, maxLimit, lineX); segments.insert(vertSeg); } @@ -1392,7 +1403,7 @@ static void processEventHori(Router *router, NodeSet& scanline, double minLimit = v->firstPointAbove(1); double maxLimit = v->firstPointBelow(1); bool inShape = v->isInsideShape(1); - + if (!inShape || (centreVert->visDirections & ConnDirUp)) { segments.insert(LineSegment(minLimit, cp.y, e->pos)); @@ -1403,13 +1414,13 @@ static void processEventHori(Router *router, NodeSet& scanline, } } } - + if ( ((pass == 3) && (e->type == Close)) || ((pass == 2) && (e->type == ConnPoint)) ) { // Clean up neighbour pointers. Node *l = v->firstAbove, *r = v->firstBelow; - if (l != NULL) + if (l != NULL) { l->firstBelow = v->firstBelow; } @@ -1455,8 +1466,8 @@ extern void generateStaticOrthogonalVisGraph(Router *router) ++shRefIt; } - for (VertInf *curr = router->vertices.connsBegin(); - curr && (curr != router->vertices.shapesBegin()); + for (VertInf *curr = router->vertices.connsBegin(); + curr && (curr != router->vertices.shapesBegin()); curr = curr->lstNext) { Point& point = curr->point; @@ -1485,7 +1496,7 @@ extern void generateStaticOrthogonalVisGraph(Router *router) { for (unsigned j = posStartIndex; j < posFinishIndex; ++j) { - processEventVert(router, scanline, segments, + processEventVert(router, scanline, segments, events[j], pass); } } @@ -1500,7 +1511,7 @@ extern void generateStaticOrthogonalVisGraph(Router *router) posStartIndex = i; } - // Do the first sweep event handling -- building the correct + // Do the first sweep event handling -- building the correct // structure of the scanline. const int pass = 1; processEventVert(router, scanline, segments, events[i], pass); @@ -1529,8 +1540,8 @@ extern void generateStaticOrthogonalVisGraph(Router *router) ++shRefIt; } - for (VertInf *curr = router->vertices.connsBegin(); - curr && (curr != router->vertices.shapesBegin()); + for (VertInf *curr = router->vertices.connsBegin(); + curr && (curr != router->vertices.shapesBegin()); curr = curr->lstNext) { Point& point = curr->point; @@ -1555,11 +1566,11 @@ extern void generateStaticOrthogonalVisGraph(Router *router) { for (unsigned j = posStartIndex; j < posFinishIndex; ++j) { - processEventHori(router, scanline, vertSegments, + processEventHori(router, scanline, vertSegments, events[j], pass); } } - + // Process the merged line segments. vertSegments.list().sort(); for (SegmentList::iterator curr = vertSegments.list().begin(); @@ -1579,7 +1590,7 @@ extern void generateStaticOrthogonalVisGraph(Router *router) posStartIndex = i; } - // Do the first sweep event handling -- building the correct + // Do the first sweep event handling -- building the correct // structure of the scanline. const int pass = 1; processEventHori(router, scanline, vertSegments, events[i], pass); @@ -1593,13 +1604,13 @@ extern void generateStaticOrthogonalVisGraph(Router *router) // Add portions of the horizontal line that are after the final vertical // position we considered. - for (SegmentList::iterator it = segments.list().begin(); + for (SegmentList::iterator it = segments.list().begin(); it != segments.list().end(); ) { LineSegment& horiLine = *it; horiLine.addEdgeHorizontal(router); - + size_t dim = XDIM; // x-dimension horiLine.generateVisibilityEdgesFromBreakpointSet(router, dim); @@ -1615,20 +1626,20 @@ extern void generateStaticOrthogonalVisGraph(Router *router) -// Processes sweep events used to determine each horizontal and vertical -// line segment in a connector's channel of visibility. +// Processes sweep events used to determine each horizontal and vertical +// line segment in a connector's channel of visibility. // Four calls to this function are made at each position by the scanline: // 1) Handle all Close event processing. // 2) Remove Close event objects from the scanline. // 3) Add Open event objects to the scanline. // 4) Handle all Open event processing. // -static void processShiftEvent(Router *router, NodeSet& scanline, - ShiftSegmentList& segments, Event *e, size_t dim, - unsigned int pass) +static void processShiftEvent(Router */*router*/, NodeSet& scanline, + ShiftSegmentList& /*segments*/, Event *e, size_t dim, + unsigned int pass) { Node *v = e->v; - + if ( ((pass == 3) && (e->type == Open)) || ((pass == 3) && (e->type == SegOpen)) ) { @@ -1638,21 +1649,21 @@ static void processShiftEvent(Router *router, NodeSet& scanline, NodeSet::iterator it = v->iter; // Work out neighbours - if (it != scanline.begin()) + if (it != scanline.begin()) { Node *u = *(--it); v->firstAbove = u; u->firstBelow = v; } it = v->iter; - if (++it != scanline.end()) + if (++it != scanline.end()) { Node *u = *it; v->firstBelow = u; u->firstAbove = v; } } - + if ( ((pass == 4) && (e->type == Open)) || ((pass == 4) && (e->type == SegOpen)) || ((pass == 1) && (e->type == SegClose)) || @@ -1664,9 +1675,9 @@ static void processShiftEvent(Router *router, NodeSet& scanline, double minLimit = v->firstObstacleAbove(dim); double maxLimit = v->firstObstacleBelow(dim); - v->ss->minSpaceLimit = + v->ss->minSpaceLimit = std::max(minLimit, v->ss->minSpaceLimit); - v->ss->maxSpaceLimit = + v->ss->maxSpaceLimit = std::min(maxLimit, v->ss->maxSpaceLimit); } else @@ -1675,13 +1686,13 @@ static void processShiftEvent(Router *router, NodeSet& scanline, v->markShiftSegmentsBelow(dim); } } - + if ( ((pass == 2) && (e->type == SegClose)) || ((pass == 2) && (e->type == Close)) ) { // Clean up neighbour pointers. Node *l = v->firstAbove, *r = v->firstBelow; - if (l != NULL) + if (l != NULL) { l->firstBelow = v->firstBelow; } @@ -1698,7 +1709,7 @@ static void processShiftEvent(Router *router, NodeSet& scanline, } -static void buildOrthogonalChannelInfo(Router *router, +static void buildOrthogonalChannelInfo(Router *router, const size_t dim, ShiftSegmentList& segmentList) { if (router->routingPenalty(segmentPenalty) == 0) @@ -1710,15 +1721,15 @@ static void buildOrthogonalChannelInfo(Router *router, size_t altDim = (dim + 1) % 2; // For each connector. - for (ConnRefList::const_iterator curr = router->connRefs.begin(); - curr != router->connRefs.end(); ++curr) + for (ConnRefList::const_iterator curr = router->connRefs.begin(); + curr != router->connRefs.end(); ++curr) { if ((*curr)->routingType() != ConnType_Orthogonal) { continue; } Polygon& displayRoute = (*curr)->displayRoute(); - // Determine all line segments that we are interested in shifting. + // Determine all line segments that we are interested in shifting. // We don't consider the first or last segment of a path. for (size_t i = 1; i < displayRoute.size(); ++i) { @@ -1732,12 +1743,12 @@ static void buildOrthogonalChannelInfo(Router *router, indexLow = i; indexHigh = i - 1; } - COLA_ASSERT(displayRoute.at(indexLow)[altDim] < + COLA_ASSERT(displayRoute.at(indexLow)[altDim] < displayRoute.at(indexHigh)[altDim]); if ((i == 1) || ((i + 1) == displayRoute.size())) { - // The first and last segment of a connector can't be + // The first and last segment of a connector can't be // shifted. We call them fixed segments. Note: this // will change if we later allow connection channels. segmentList.push_back( @@ -1753,15 +1764,15 @@ static void buildOrthogonalChannelInfo(Router *router, double prevPos = displayRoute.ps[i - 2][dim]; double nextPos = displayRoute.ps[i + 1][dim]; if (((prevPos < displayRoute.ps[i][dim]) && - (nextPos > displayRoute.ps[i][dim])) + (nextPos > displayRoute.ps[i][dim])) || ((prevPos > displayRoute.ps[i][dim]) && (nextPos < displayRoute.ps[i][dim])) ) { isSBend = true; - // Determine limits if the s-bend is not due to an - // obstacle. In this case we need to limit the channel + // Determine limits if the s-bend is not due to an + // obstacle. In this case we need to limit the channel // to the span of the adjoining segments to this one. if ((prevPos < displayRoute.ps[i][dim]) && (nextPos > displayRoute.ps[i][dim])) @@ -1778,7 +1789,7 @@ static void buildOrthogonalChannelInfo(Router *router, else { // isCBend: Both adjoining segments are in the same - // direction. We indicate this for later by setting + // direction. We indicate this for later by setting // the maxLim or minLim to the segment position. if (prevPos < displayRoute.ps[i][dim]) { @@ -1790,7 +1801,7 @@ static void buildOrthogonalChannelInfo(Router *router, } } - segmentList.push_back(ShiftSegment(*curr, indexLow, + segmentList.push_back(ShiftSegment(*curr, indexLow, indexHigh, isSBend, dim, minLim, maxLim)); } } @@ -1800,7 +1811,7 @@ static void buildOrthogonalChannelInfo(Router *router, // There are no segments, so we can just return now. return; } - + // Do a sweep and shift these segments. const size_t n = router->shapeRefs.size(); const size_t cpn = segmentList.size(); @@ -1821,7 +1832,7 @@ static void buildOrthogonalChannelInfo(Router *router, ++shRefIt; } - for (ShiftSegmentList::iterator curr = segmentList.begin(); + for (ShiftSegmentList::iterator curr = segmentList.begin(); curr != segmentList.end(); ++curr) { const Point& lowPt = curr->lowPoint(); @@ -1853,7 +1864,7 @@ static void buildOrthogonalChannelInfo(Router *router, { for (unsigned j = posStartIndex; j < posFinishIndex; ++j) { - processShiftEvent(router, scanline, segmentList, events[j], + processShiftEvent(router, scanline, segmentList, events[j], dim, pass); } } @@ -1868,7 +1879,7 @@ static void buildOrthogonalChannelInfo(Router *router, posStartIndex = i; } - // Do the first sweep event handling -- building the correct + // Do the first sweep event handling -- building the correct // structure of the scanline. const int pass = 1; processShiftEvent(router, scanline, segmentList, events[i], @@ -1886,8 +1897,8 @@ static void buildOrthogonalChannelInfo(Router *router, static void simplifyOrthogonalRoutes(Router *router) { // Simplify routes. - for (ConnRefList::const_iterator curr = router->connRefs.begin(); - curr != router->connRefs.end(); ++curr) + for (ConnRefList::const_iterator curr = router->connRefs.begin(); + curr != router->connRefs.end(); ++curr) { if ((*curr)->routingType() != ConnType_Orthogonal) { @@ -1898,7 +1909,7 @@ static void simplifyOrthogonalRoutes(Router *router) } -static void buildOrthogonalNudgingOrderInfo(Router *router, +static void buildOrthogonalNudgingOrderInfo(Router *router, PtOrderMap& pointOrders) { // Simplify routes. @@ -1907,46 +1918,46 @@ static void buildOrthogonalNudgingOrderInfo(Router *router, int crossingsN = 0; // Do segment splitting. - for (ConnRefList::const_iterator curr = router->connRefs.begin(); - curr != router->connRefs.end(); ++curr) + for (ConnRefList::const_iterator curr = router->connRefs.begin(); + curr != router->connRefs.end(); ++curr) { if ((*curr)->routingType() != ConnType_Orthogonal) { continue; } ConnRef *conn = *curr; - - for (ConnRefList::const_iterator curr2 = router->connRefs.begin(); - curr2 != router->connRefs.end(); ++curr2) + + for (ConnRefList::const_iterator curr2 = router->connRefs.begin(); + curr2 != router->connRefs.end(); ++curr2) { if ((*curr2)->routingType() != ConnType_Orthogonal) { continue; } ConnRef *conn2 = *curr2; - + if (conn == conn2) { continue; } - + Avoid::Polygon& route = conn->displayRoute(); Avoid::Polygon& route2 = conn2->displayRoute(); splitBranchingSegments(route2, true, route); } } - for (ConnRefList::const_iterator curr = router->connRefs.begin(); - curr != router->connRefs.end(); ++curr) + for (ConnRefList::const_iterator curr = router->connRefs.begin(); + curr != router->connRefs.end(); ++curr) { if ((*curr)->routingType() != ConnType_Orthogonal) { continue; } ConnRef *conn = *curr; - - for (ConnRefList::const_iterator curr2 = curr; - curr2 != router->connRefs.end(); ++curr2) + + for (ConnRefList::const_iterator curr2 = curr; + curr2 != router->connRefs.end(); ++curr2) { if ((*curr2)->routingType() != ConnType_Orthogonal) { @@ -1958,7 +1969,7 @@ static void buildOrthogonalNudgingOrderInfo(Router *router, { continue; } - + Avoid::Polygon& route = conn->displayRoute(); Avoid::Polygon& route2 = conn2->displayRoute(); bool checkForBranchingSegments = false; @@ -1966,8 +1977,8 @@ static void buildOrthogonalNudgingOrderInfo(Router *router, for (size_t i = 1; i < route.size(); ++i) { const bool finalSegment = ((i + 1) == route.size()); - crossings += countRealCrossings(route2, true, route, i, - checkForBranchingSegments, finalSegment, NULL, + crossings += countRealCrossings(route2, true, route, i, + checkForBranchingSegments, finalSegment, NULL, &pointOrders, conn2, conn).first; } if (crossings > 0) @@ -1976,7 +1987,7 @@ static void buildOrthogonalNudgingOrderInfo(Router *router, } } } - + // Sort the point orders. PtOrderMap::iterator finish = pointOrders.end(); for (PtOrderMap::iterator it = pointOrders.begin(); it != finish; ++it) @@ -1992,7 +2003,7 @@ static void buildOrthogonalNudgingOrderInfo(Router *router, } -class CmpLineOrder +class CmpLineOrder { public: CmpLineOrder(PtOrderMap& ord, const size_t dim) @@ -2007,11 +2018,11 @@ class CmpLineOrder { *comparable = true; } - Point lhsLow = lhs.lowPoint(); - Point rhsLow = rhs.lowPoint(); + Point lhsLow = lhs.lowPoint(); + Point rhsLow = rhs.lowPoint(); #ifndef NDEBUG - const Point& lhsHigh = lhs.highPoint(); - const Point& rhsHigh = rhs.highPoint(); + const Point& lhsHigh = lhs.highPoint(); + const Point& rhsHigh = rhs.highPoint(); #endif size_t altDim = (dimension + 1) % 2; @@ -2022,9 +2033,9 @@ class CmpLineOrder { return lhsLow[dimension] < rhsLow[dimension]; } - - // If one of these is fixed, then determine order based on - // fixed segment, that is, order so the fixed segment doesn't + + // If one of these is fixed, then determine order based on + // fixed segment, that is, order so the fixed segment doesn't // block movement. bool oneIsFixed = false; const int lhsFixedOrder = lhs.fixedOrder(oneIsFixed); @@ -2034,8 +2045,8 @@ class CmpLineOrder return lhsFixedOrder < rhsFixedOrder; } - // C-bends that did not have a clear order with s-bends might - // not have a good ordering here, so compare their order in + // C-bends that did not have a clear order with s-bends might + // not have a good ordering here, so compare their order in // terms of C-bend direction and S-bends and use that if it // differs for the two segments. const int lhsOrder = lhs.order(); @@ -2056,7 +2067,7 @@ class CmpLineOrder { // A value for rhsPos or lhsPos mean the points are not directly // comparable, meaning they are at the same position but cannot - // overlap (they are just collinear. The relative order for + // overlap (they are just collinear. The relative order for // these segments is not important since we do not constrain // them against each other. //COLA_ASSERT(lhs.overlapsWith(rhs, dimension) == false); @@ -2076,13 +2087,13 @@ class CmpLineOrder }; -// We can use the normaal sort algorithm for lists since it is not possible -// to comapre all elements, but there will be an ordering defined between -// most of the elements. Hence we order these, using insertion sort, and -// the case of them not being able to be compared is handled by not setting +// We can use the normaal sort algorithm for lists since it is not possible +// to comapre all elements, but there will be an ordering defined between +// most of the elements. Hence we order these, using insertion sort, and +// the case of them not being able to be compared is handled by not setting // up any constraints between such segments when doing the nudging. // -static ShiftSegmentList linesort(ShiftSegmentList origList, +static ShiftSegmentList linesort(ShiftSegmentList origList, CmpLineOrder& comparison) { ShiftSegmentList resultList; @@ -2119,7 +2130,7 @@ static ShiftSegmentList linesort(ShiftSegmentList origList, typedef std::list ShiftSegmentPtrList; -static void nudgeOrthogonalRoutes(Router *router, size_t dimension, +static void nudgeOrthogonalRoutes(Router *router, size_t dimension, PtOrderMap& pointOrders, ShiftSegmentList& segmentList) { // Do the actual nudging. @@ -2160,7 +2171,7 @@ static void nudgeOrthogonalRoutes(Router *router, size_t dimension, } CmpLineOrder lineSortComp(pointOrders, dimension); currentRegion = linesort(currentRegion, lineSortComp); - + if (currentRegion.size() == 1) { // Save creating the solver instance if there is just one @@ -2188,7 +2199,7 @@ static void nudgeOrthogonalRoutes(Router *router, size_t dimension, currSegment != currentRegion.end(); ++currSegment) { Point& lowPt = currSegment->lowPoint(); - + // Create a solver variable for the position of this segment. int varID = freeID; double idealPos = lowPt[dimension]; @@ -2197,7 +2208,7 @@ static void nudgeOrthogonalRoutes(Router *router, size_t dimension, { COLA_ASSERT(currSegment->minSpaceLimit > -CHANNEL_MAX); COLA_ASSERT(currSegment->maxSpaceLimit < CHANNEL_MAX); - + // For s-bends, take the middle as ideal. idealPos = currSegment->minSpaceLimit + ((currSegment->maxSpaceLimit - @@ -2211,7 +2222,7 @@ static void nudgeOrthogonalRoutes(Router *router, size_t dimension, } else { - // Set a higher weight for c-bends to stop them sometimes + // Set a higher weight for c-bends to stop them sometimes // getting pushed out into channels by more-free connectors // to the "inner" side of them. weight = strongWeight; @@ -2234,10 +2245,10 @@ static void nudgeOrthogonalRoutes(Router *router, size_t dimension, if (currSegment->overlapsWith(*prevSeg, dimension) && (!(currSegment->fixed) || !(prevSeg->fixed))) { - // If there is a previous segment to the left that - // could overlap this in the shift direction, then + // If there is a previous segment to the left that + // could overlap this in the shift direction, then // constrain the two segments to be separated. - // Though don't add the constraint if both the + // Though don't add the constraint if both the // segments are fixed in place. cs.push_back(new Constraint(prevVar, vs[index], router->orthogonalNudgeDistance())); @@ -2251,21 +2262,21 @@ static void nudgeOrthogonalRoutes(Router *router, size_t dimension, if (!currSegment->fixed) { - // If this segment sees a channel boundary to its left, + // If this segment sees a channel boundary to its left, // then constrain its placement as such. if (currSegment->minSpaceLimit > -CHANNEL_MAX) { - vs.push_back(new Variable(fixedID, + vs.push_back(new Variable(fixedID, currSegment->minSpaceLimit, fixedWeight)); - cs.push_back(new Constraint(vs[vs.size() - 1], vs[index], + cs.push_back(new Constraint(vs[vs.size() - 1], vs[index], 0.0)); } - - // If this segment sees a channel boundary to its right, + + // If this segment sees a channel boundary to its right, // then constrain its placement as such. if (currSegment->maxSpaceLimit < CHANNEL_MAX) { - vs.push_back(new Variable(fixedID, + vs.push_back(new Variable(fixedID, currSegment->maxSpaceLimit, fixedWeight)); cs.push_back(new Constraint(vs[index], vs[vs.size() - 1], 0.0)); @@ -2281,7 +2292,7 @@ static void nudgeOrthogonalRoutes(Router *router, size_t dimension, IncSolver f(vs,cs); f.solve(); bool satisfied = true; - for (size_t i = 0; i < vs.size(); ++i) + for (size_t i = 0; i < vs.size(); ++i) { if (vs[i]->id == fixedID) { @@ -2323,7 +2334,7 @@ extern void improveOrthogonalRoutes(Router *router) { // Build nudging info. // XXX: We need to build the point orders separately in each - // dimension since things move. There is probably a more + // dimension since things move. There is probably a more // efficient way to do this. PtOrderMap pointOrders; buildOrthogonalNudgingOrderInfo(router, pointOrders); diff --git a/src/libavoid/router.cpp b/src/libavoid/router.cpp index 754c464b4..ab13a981b 100644 --- a/src/libavoid/router.cpp +++ b/src/libavoid/router.cpp @@ -12,12 +12,12 @@ * 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 + * 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * Author(s): Michael Wybrow */ @@ -73,7 +73,7 @@ class ActionInfo { } ShapeRef *shape(void) const { - COLA_ASSERT((type == ShapeMove) || (type == ShapeAdd) || + COLA_ASSERT((type == ShapeMove) || (type == ShapeAdd) || (type == ShapeRemove)); return (static_cast (objPtr)); } @@ -189,8 +189,8 @@ void Router::modifyConnector(ConnRef *conn, const unsigned int type, const ConnEnd& connEnd) { ActionInfo modInfo(ConnChange, conn); - - ActionInfoList::iterator found = + + ActionInfoList::iterator found = find(actionList.begin(), actionList.end(), modInfo); if (found == actionList.end()) { @@ -212,8 +212,8 @@ void Router::modifyConnector(ConnRef *conn, const unsigned int type, void Router::modifyConnector(ConnRef *conn) { ActionInfo modInfo(ConnChange, conn); - - ActionInfoList::iterator found = + + ActionInfoList::iterator found = find(actionList.begin(), actionList.end(), modInfo); if (found == actionList.end()) { @@ -231,7 +231,7 @@ void Router::removeQueuedConnectorActions(ConnRef *conn) { ActionInfo modInfo(ConnChange, conn); - ActionInfoList::iterator found = + ActionInfoList::iterator found = find(actionList.begin(), actionList.end(), modInfo); if (found != actionList.end()) { @@ -245,14 +245,14 @@ void Router::addShape(ShapeRef *shape) // There shouldn't be remove events or move events for the same shape // already in the action list. // XXX: Possibly we could handle this by ordering them intelligently. - COLA_ASSERT(find(actionList.begin(), actionList.end(), + COLA_ASSERT(find(actionList.begin(), actionList.end(), ActionInfo(ShapeRemove, shape)) == actionList.end()); - COLA_ASSERT(find(actionList.begin(), actionList.end(), + COLA_ASSERT(find(actionList.begin(), actionList.end(), ActionInfo(ShapeMove, shape)) == actionList.end()); ActionInfo addInfo(ShapeAdd, shape); - - ActionInfoList::iterator found = + + ActionInfoList::iterator found = find(actionList.begin(), actionList.end(), addInfo); if (found == actionList.end()) { @@ -268,14 +268,14 @@ void Router::addShape(ShapeRef *shape) void Router::removeShape(ShapeRef *shape) { - // There shouldn't be add events events for the same shape already + // There shouldn't be add events events for the same shape already // in the action list. // XXX: Possibly we could handle this by ordering them intelligently. - COLA_ASSERT(find(actionList.begin(), actionList.end(), + COLA_ASSERT(find(actionList.begin(), actionList.end(), ActionInfo(ShapeAdd, shape)) == actionList.end()); // Delete any ShapeMove entries for this shape in the action list. - ActionInfoList::iterator found = find(actionList.begin(), + ActionInfoList::iterator found = find(actionList.begin(), actionList.end(), ActionInfo(ShapeMove, shape)); if (found != actionList.end()) { @@ -306,16 +306,16 @@ void Router::moveShape(ShapeRef *shape, const double xDiff, const double yDiff) } -void Router::moveShape(ShapeRef *shape, const Polygon& newPoly, +void Router::moveShape(ShapeRef *shape, const Polygon& newPoly, const bool first_move) { // There shouldn't be remove events or add events for the same shape // already in the action list. // XXX: Possibly we could handle this by ordering them intelligently. - COLA_ASSERT(find(actionList.begin(), actionList.end(), + COLA_ASSERT(find(actionList.begin(), actionList.end(), ActionInfo(ShapeRemove, shape)) == actionList.end()); - - if (find(actionList.begin(), actionList.end(), + + if (find(actionList.begin(), actionList.end(), ActionInfo(ShapeAdd, shape)) != actionList.end()) { // The Add is enough, no need for the Move action too. @@ -325,7 +325,7 @@ void Router::moveShape(ShapeRef *shape, const Polygon& newPoly, ActionInfo moveInfo(ShapeMove, shape, newPoly, first_move); // Sanely cope with the case where the user requests moving the same // shape multiple times before rerouting connectors. - ActionInfoList::iterator found = + ActionInfoList::iterator found = find(actionList.begin(), actionList.end(), moveInfo); if (found != actionList.end()) @@ -339,7 +339,7 @@ void Router::moveShape(ShapeRef *shape, const Polygon& newPoly, // leave the firstMove setting alone. found->newPoly = newPoly; } - else + else { actionList.push_back(moveInfo); } @@ -380,7 +380,7 @@ void Router::destroyOrthogonalVisGraph(void) void Router::regenerateStaticBuiltGraph(void) { - // Here we do talks involved in updating the static-built visibility + // Here we do talks involved in updating the static-built visibility // graph (if necessary) before we do any routing. if (_staticGraphInvalidated) { @@ -391,7 +391,7 @@ void Router::regenerateStaticBuiltGraph(void) timers.Register(tmOrthogGraph, timerStart); // Regenerate a new visibility graph. generateStaticOrthogonalVisGraph(this); - + timers.Stop(); } _staticGraphInvalidated = false; @@ -401,11 +401,11 @@ void Router::regenerateStaticBuiltGraph(void) bool Router::shapeInQueuedActionList(ShapeRef *shape) const { - bool foundAdd = find(actionList.begin(), actionList.end(), + bool foundAdd = find(actionList.begin(), actionList.end(), ActionInfo(ShapeAdd, shape)) != actionList.end(); - bool foundRem = find(actionList.begin(), actionList.end(), + bool foundRem = find(actionList.begin(), actionList.end(), ActionInfo(ShapeRemove, shape)) != actionList.end(); - bool foundMove = find(actionList.begin(), actionList.end(), + bool foundMove = find(actionList.begin(), actionList.end(), ActionInfo(ShapeMove, shape)) != actionList.end(); return (foundAdd || foundRem || foundMove); @@ -456,21 +456,21 @@ bool Router::processTransaction(void) // o Remove entries related to this shape's vertices shape->removeFromGraph(); - + if (SelectiveReroute && (!isMove || notPartialTime || first_move)) { markConnectors(shape); } adjustContainsWithDel(pid); - + // Ignore this shape for visibility. // XXX: We don't really need to do this if we're not using Partial // Feedback. Without this the blocked edges still route // around the shape until it leaves the connector. shape->makeInactive(); } - + if (seenShapeMovesOrDeletes && _polyLineRouting) { if (InvisibilityGrph) @@ -478,7 +478,7 @@ bool Router::processTransaction(void) for (curr = actionList.begin(); curr != finish; ++curr) { ActionInfo& actInf = *curr; - if (!((actInf.type == ShapeRemove) || + if (!((actInf.type == ShapeRemove) || (actInf.type == ShapeMove))) { // Not a move or remove action, so don't do anything. @@ -513,7 +513,7 @@ bool Router::processTransaction(void) // Restore this shape for visibility. shape->makeActive(); - + if (isMove) { shape->setNewPoly(newPoly); @@ -559,7 +559,7 @@ bool Router::processTransaction(void) } // Clear the actionList. actionList.clear(); - + _staticGraphInvalidated = true; rerouteAndCallbackConnectors(); @@ -570,7 +570,7 @@ bool Router::processTransaction(void) void Router::addCluster(ClusterRef *cluster) { cluster->makeActive(); - + unsigned int pid = cluster->id(); ReferencingPolygon& poly = cluster->polygon(); @@ -581,9 +581,9 @@ void Router::addCluster(ClusterRef *cluster) void Router::delCluster(ClusterRef *cluster) { cluster->makeInactive(); - + unsigned int pid = cluster->id(); - + adjustClustersWithDel(pid); } @@ -605,9 +605,9 @@ unsigned int Router::assignId(const unsigned int suggestedId) { // If the suggestedId is zero, then we assign the object the next // smallest unassigned ID, otherwise we trust the ID given is unique. - unsigned int assignedId = (suggestedId == 0) ? + unsigned int assignedId = (suggestedId == 0) ? (_largestAssignedId + 1) : suggestedId; - + // Have the router record if this ID is larger than the _largestAssignedId. _largestAssignedId = std::max(_largestAssignedId, assignedId); @@ -619,17 +619,17 @@ unsigned int Router::assignId(const unsigned int suggestedId) // Returns whether the given ID is unique among all objects known by the - // router. Outputs a warning if the ID is found ore than once. + // router. Outputs a warning if the ID is found ore than once. // It is expected this is only going to be called from assertions while // debugging, so efficiency is not an issue and we just iterate over all // objects. -bool Router::idIsUnique(const unsigned int id) const +bool Router::idIsUnique(const unsigned int id) const { unsigned int count = 0; // Examine shapes. - for (ShapeRefList::const_iterator i = shapeRefs.begin(); - i != shapeRefs.end(); ++i) + for (ShapeRefList::const_iterator i = shapeRefs.begin(); + i != shapeRefs.end(); ++i) { if ((*i)->id() == id) { @@ -638,8 +638,8 @@ bool Router::idIsUnique(const unsigned int id) const } // Examine connectors. - for (ConnRefList::const_iterator i = connRefs.begin(); - i != connRefs.end(); ++i) + for (ConnRefList::const_iterator i = connRefs.begin(); + i != connRefs.end(); ++i) { if ((*i)->id() == id) { @@ -648,8 +648,8 @@ bool Router::idIsUnique(const unsigned int id) const } // Examine clusters. - for (ClusterRefList::const_iterator i = clusterRefs.begin(); - i != clusterRefs.end(); ++i) + for (ClusterRefList::const_iterator i = clusterRefs.begin(); + i != clusterRefs.end(); ++i) { if ((*i)->id() == id) { @@ -679,13 +679,13 @@ void Router::attachedConns(IntList &conns, const unsigned int shapeId, const unsigned int type) { ConnRefList::const_iterator fin = connRefs.end(); - for (ConnRefList::const_iterator i = connRefs.begin(); i != fin; ++i) + for (ConnRefList::const_iterator i = connRefs.begin(); i != fin; ++i) { - if ((type & runningTo) && ((*i)->_dstId == shapeId)) + if ((type & runningTo) && ((*i)->_dstId == shapeId)) { conns.push_back((*i)->_id); } - else if ((type & runningFrom) && ((*i)->_srcId == shapeId)) + else if ((type & runningFrom) && ((*i)->_srcId == shapeId)) { conns.push_back((*i)->_id); } @@ -699,9 +699,9 @@ void Router::attachedShapes(IntList &shapes, const unsigned int shapeId, const unsigned int type) { ConnRefList::const_iterator fin = connRefs.end(); - for (ConnRefList::const_iterator i = connRefs.begin(); i != fin; ++i) + for (ConnRefList::const_iterator i = connRefs.begin(); i != fin; ++i) { - if ((type & runningTo) && ((*i)->_dstId == shapeId)) + if ((type & runningTo) && ((*i)->_dstId == shapeId)) { if ((*i)->_srcId != 0) { @@ -709,7 +709,7 @@ void Router::attachedShapes(IntList &shapes, const unsigned int shapeId, shapes.push_back((*i)->_srcId); } } - else if ((type & runningFrom) && ((*i)->_srcId == shapeId)) + else if ((type & runningFrom) && ((*i)->_srcId == shapeId)) { if ((*i)->_dstId != 0) { @@ -721,19 +721,19 @@ void Router::attachedShapes(IntList &shapes, const unsigned int shapeId, } - // It's intended this function is called after visibility changes - // resulting from shape movement have happened. It will alert + // It's intended this function is called after visibility changes + // resulting from shape movement have happened. It will alert // rerouted connectors (via a callback) that they need to be redrawn. void Router::rerouteAndCallbackConnectors(void) { std::set reroutedConns; ConnRefList::const_iterator fin = connRefs.end(); - - // Updating the orthogonal visibility graph if necessary. + + // Updating the orthogonal visibility graph if necessary. regenerateStaticBuiltGraph(); timers.Register(tmOrthogRoute, timerStart); - for (ConnRefList::const_iterator i = connRefs.begin(); i != fin; ++i) + for (ConnRefList::const_iterator i = connRefs.begin(); i != fin; ++i) { (*i)->_needs_repaint = false; bool rerouted = (*i)->generatePath(); @@ -751,7 +751,7 @@ void Router::rerouteAndCallbackConnectors(void) improveOrthogonalRoutes(this); // Alert connectors that they need redrawing. - for (ConnRefList::const_iterator i = connRefs.begin(); i != fin; ++i) + for (ConnRefList::const_iterator i = connRefs.begin(); i != fin; ++i) { (*i)->_needs_repaint = true; (*i)->performCallback(); @@ -770,18 +770,18 @@ void Router::improveCrossings(void) // No penalties, return. return; } - + // Find crossings and reroute connectors. _inCrossingPenaltyReroutingStage = true; ConnRefSet crossingConns; ConnRefList::iterator fin = connRefs.end(); - for (ConnRefList::iterator i = connRefs.begin(); i != fin; ++i) + for (ConnRefList::iterator i = connRefs.begin(); i != fin; ++i) { Avoid::Polygon& iRoute = (*i)->routeRef(); ConnRefList::iterator j = i; - for (++j; j != fin; ++j) + for (++j; j != fin; ++j) { - if ((crossingConns.find(*i) != crossingConns.end()) && + if ((crossingConns.find(*i) != crossingConns.end()) && (crossingConns.find(*j) != crossingConns.end())) { // We already know both these have crossings. @@ -795,13 +795,13 @@ void Router::improveCrossings(void) { const bool finalSegment = ((jInd + 1) == jRoute.size()); CrossingsInfoPair crossingInfo = countRealCrossings( - iRoute, true, jRoute, jInd, false, + iRoute, true, jRoute, jInd, false, finalSegment, NULL, NULL, *i, *j); - - if ((shared_path_penalty > 0) && - (crossingInfo.second & CROSSING_SHARES_PATH) && - (crossingInfo.second & CROSSING_SHARES_FIXED_SEGMENT) && - !(crossingInfo.second & CROSSING_SHARES_PATH_AT_END)) + + if ((shared_path_penalty > 0) && + (crossingInfo.second & CROSSING_SHARES_PATH) && + (crossingInfo.second & CROSSING_SHARES_FIXED_SEGMENT) && + !(crossingInfo.second & CROSSING_SHARES_PATH_AT_END)) { // We are penalising fixedSharedPaths and there is a // fixedSharedPath. @@ -823,7 +823,7 @@ void Router::improveCrossings(void) } } - for (ConnRefSet::iterator i = crossingConns.begin(); + for (ConnRefSet::iterator i = crossingConns.begin(); i != crossingConns.end(); ++i) { ConnRef *conn = *i; @@ -831,7 +831,7 @@ void Router::improveCrossings(void) // XXX: Could we free these routes here for extra savings? // conn->freeRoutes(); } - for (ConnRefSet::iterator i = crossingConns.begin(); + for (ConnRefSet::iterator i = crossingConns.begin(); i != crossingConns.end(); ++i) { ConnRef *conn = *i; @@ -862,9 +862,9 @@ void Router::newBlockingShape(const Polygon& poly, int pid) bool blocked = false; bool countBorder = false; - bool ep_in_poly1 = !(eID1.isShape) ? + bool ep_in_poly1 = !(eID1.isShape) ? inPoly(poly, e1, countBorder) : false; - bool ep_in_poly2 = !(eID2.isShape) ? + bool ep_in_poly2 = !(eID2.isShape) ? inPoly(poly, e2, countBorder) : false; if (ep_in_poly1 || ep_in_poly2) { @@ -879,7 +879,7 @@ void Router::newBlockingShape(const Polygon& poly, int pid) size_t pt_n = (pt_i == (poly.size() - 1)) ? 0 : pt_i + 1; const Point& pi = poly.ps[pt_i]; const Point& pn = poly.ps[pt_n]; - if (segmentShapeIntersect(e1, e2, pi, pn, + if (segmentShapeIntersect(e1, e2, pi, pn, seenIntersectionAtEndpoint)) { blocked = true; @@ -983,7 +983,7 @@ void Router::generateContains(VertInf *pt) // Computer enclosing Clusters ClusterRefList::const_iterator clFinish = clusterRefs.end(); - for (ClusterRefList::const_iterator i = clusterRefs.begin(); + for (ClusterRefList::const_iterator i = clusterRefs.begin(); i != clFinish; ++i) { if (inPolyGen((*i)->polygon(), pt->point)) @@ -994,7 +994,7 @@ void Router::generateContains(VertInf *pt) } -void Router::adjustClustersWithAdd(const PolygonInterface& poly, +void Router::adjustClustersWithAdd(const PolygonInterface& poly, const int p_cluster) { for (VertInf *k = vertices.connsBegin(); k != vertices.shapesBegin(); @@ -1422,11 +1422,11 @@ static void reduceRange(double& val) bool Router::existsOrthogonalPathOverlap(void) { ConnRefList::iterator fin = connRefs.end(); - for (ConnRefList::iterator i = connRefs.begin(); i != fin; ++i) + for (ConnRefList::iterator i = connRefs.begin(); i != fin; ++i) { Avoid::Polygon iRoute = (*i)->displayRoute(); ConnRefList::iterator j = i; - for (++j; j != fin; ++j) + for (++j; j != fin; ++j) { // Determine if this pair overlap Avoid::Polygon jRoute = (*j)->displayRoute(); @@ -1435,12 +1435,12 @@ bool Router::existsOrthogonalPathOverlap(void) { const bool finalSegment = ((jInd + 1) == jRoute.size()); CrossingsInfoPair crossingInfo = countRealCrossings( - iRoute, true, jRoute, jInd, true, + iRoute, true, jRoute, jInd, true, finalSegment, NULL, NULL, *i, *j); - - if ((crossingInfo.second & CROSSING_SHARES_PATH) && - (crossingInfo.second & CROSSING_SHARES_FIXED_SEGMENT) && - !(crossingInfo.second & CROSSING_SHARES_PATH_AT_END)) + + if ((crossingInfo.second & CROSSING_SHARES_PATH) && + (crossingInfo.second & CROSSING_SHARES_FIXED_SEGMENT) && + !(crossingInfo.second & CROSSING_SHARES_PATH_AT_END)) { // We looking for fixedSharedPaths and there is a // fixedSharedPath. @@ -1456,11 +1456,11 @@ bool Router::existsOrthogonalPathOverlap(void) bool Router::existsOrthogonalTouchingCorners(void) { ConnRefList::iterator fin = connRefs.end(); - for (ConnRefList::iterator i = connRefs.begin(); i != fin; ++i) + for (ConnRefList::iterator i = connRefs.begin(); i != fin; ++i) { Avoid::Polygon iRoute = (*i)->displayRoute(); ConnRefList::iterator j = i; - for (++j; j != fin; ++j) + for (++j; j != fin; ++j) { // Determine if this pair overlap Avoid::Polygon jRoute = (*j)->displayRoute(); @@ -1469,10 +1469,10 @@ bool Router::existsOrthogonalTouchingCorners(void) { const bool finalSegment = ((jInd + 1) == jRoute.size()); CrossingsInfoPair crossingInfo = countRealCrossings( - iRoute, true, jRoute, jInd, true, + iRoute, true, jRoute, jInd, true, finalSegment, NULL, NULL, *i, *j); - - if (crossingInfo.second & CROSSING_TOUCHES) + + if (crossingInfo.second & CROSSING_TOUCHES) { return true; } @@ -1514,7 +1514,7 @@ void Router::outputInstanceToSVG(std::string instanceName) reduceRange(p.x); reduceRange(p.y); - + if (p.x > -LIMIT) { minX = std::min(minX, p.x); @@ -1550,8 +1550,8 @@ void Router::outputInstanceToSVG(std::string instanceName) fprintf(fp, " PolyLineRouting | OrthogonalRouting);\n"); for (size_t p = 0; p < lastPenaltyMarker; ++p) { - fprintf(fp, " router->setRoutingPenalty((PenaltyType)%lu, %g);\n", - p, _routingPenalties[p]); + fprintf(fp, " router->setRoutingPenalty((PenaltyType)%lu, %g);\n", + static_cast(p), _routingPenalties[p]); } fprintf(fp, " router->setOrthogonalNudgeDistance(%g);\n\n", orthogonalNudgeDistance()); @@ -1559,12 +1559,12 @@ void Router::outputInstanceToSVG(std::string instanceName) while (shRefIt != shapeRefs.end()) { ShapeRef *shRef = *shRefIt; - fprintf(fp, " Polygon poly%u(%lu);\n", - shRef->id(), shRef->polygon().size()); + fprintf(fp, " Polygon poly%u(%lu);\n", + shRef->id(), static_cast(shRef->polygon().size())); for (size_t i = 0; i < shRef->polygon().size(); ++i) { - fprintf(fp, " poly%u.ps[%lu] = Point(%g, %g);\n", - shRef->id(), i, shRef->polygon().at(i).x, + fprintf(fp, " poly%u.ps[%lu] = Point(%g, %g);\n", + shRef->id(), static_cast(i), shRef->polygon().at(i).x, shRef->polygon().at(i).y); } fprintf(fp, " ShapeRef *shapeRef%u = new ShapeRef(router, poly%u, " @@ -1594,7 +1594,7 @@ void Router::outputInstanceToSVG(std::string instanceName) fprintf(fp, " connRef%u->setDestEndpoint(dstPt%u);\n", connRef->id(), connRef->id()); } - fprintf(fp, " connRef%u->setRoutingType((ConnType)%u);\n\n", + fprintf(fp, " connRef%u->setRoutingType((ConnType)%u);\n\n", connRef->id(), connRef->routingType()); ++revConnRefIt; } @@ -1605,20 +1605,20 @@ void Router::outputInstanceToSVG(std::string instanceName) fprintf(fp, "};\n"); fprintf(fp, "-->\n"); - + fprintf(fp, "\n"); shRefIt = shapeRefs.begin(); while (shRefIt != shapeRefs.end()) { ShapeRef *shRef = *shRefIt; - + fprintf(fp, "id()); for (size_t i = 0; i < shRef->polygon().size(); ++i) { - fprintf(fp, "%c %g,%g ", ((i == 0) ? 'M' : 'L'), + fprintf(fp, "%c %g,%g ", ((i == 0) ? 'M' : 'L'), shRef->polygon().at(i).x, shRef->polygon().at(i).y); } fprintf(fp, "Z\" />\n"); @@ -1635,7 +1635,7 @@ void Router::outputInstanceToSVG(std::string instanceName) ShapeRef *shRef = *shRefIt; double minX, minY, maxX, maxY; shRef->polygon().getBoundingRect(&minX, &minY, &maxX, &maxY); - + fprintf(fp, "\n", shRef->id(), minX, minY, maxX - minX, maxY - minY); @@ -1664,16 +1664,16 @@ void Router::outputInstanceToSVG(std::string instanceName) std::pair ptpair = t->points(); Point p1 = ptpair.first; Point p2 = ptpair.second; - + reduceRange(p1.x); reduceRange(p1.y); reduceRange(p2.x); reduceRange(p2.y); - + fprintf(fp, "\n", + "style=\"fill: none; stroke: %s; stroke-width: 1px;\" />\n", p1.x, p1.y, p2.x, p2.y, - (!(ids.first.isShape) || !(ids.second.isShape)) ? "green" : + (!(ids.first.isShape) || !(ids.second.isShape)) ? "green" : "red"); } fprintf(fp, "\n"); @@ -1694,16 +1694,16 @@ void Router::outputInstanceToSVG(std::string instanceName) std::pair ptpair = t->points(); Point p1 = ptpair.first; Point p2 = ptpair.second; - + reduceRange(p1.x); reduceRange(p1.y); reduceRange(p2.x); reduceRange(p2.y); - + fprintf(fp, "\n", + "style=\"fill: none; stroke: %s; stroke-width: 1px;\" />\n", p1.x, p1.y, p2.x, p2.y, - (!(ids.first.isShape) || !(ids.second.isShape)) ? "green" : + (!(ids.first.isShape) || !(ids.second.isShape)) ? "green" : "red"); } fprintf(fp, "\n"); @@ -1718,18 +1718,18 @@ void Router::outputInstanceToSVG(std::string instanceName) std::pair ptpair = t->points(); Point p1 = ptpair.first; Point p2 = ptpair.second; - + reduceRange(p1.x); reduceRange(p1.y); reduceRange(p2.x); reduceRange(p2.y); - + std::pair ids = t->ids(); fprintf(fp, "\n", + "style=\"fill: none; stroke: %s; stroke-width: 1px;\" />\n", p1.x, p1.y, p2.x, p2.y, - (!(ids.first.isShape) || !(ids.second.isShape)) ? "green" : + (!(ids.first.isShape) || !(ids.second.isShape)) ? "green" : "red"); } fprintf(fp, "\n"); @@ -1742,7 +1742,7 @@ void Router::outputInstanceToSVG(std::string instanceName) while (connRefIt != connRefs.end()) { ConnRef *connRef = *connRefIt; - + PolyLine route = connRef->route(); if (!route.empty()) { @@ -1762,7 +1762,7 @@ void Router::outputInstanceToSVG(std::string instanceName) fprintf(fp, "style=\"fill: none; stroke: black; " "stroke-width: 1px;\" />\n"); } - + ++connRefIt; } fprintf(fp, "\n"); @@ -1775,7 +1775,7 @@ void Router::outputInstanceToSVG(std::string instanceName) while (connRefIt != connRefs.end()) { ConnRef *connRef = *connRefIt; - + PolyLine route = connRef->displayRoute().curvedPolyline(8); if (!route.empty()) { @@ -1785,7 +1785,7 @@ void Router::outputInstanceToSVG(std::string instanceName) { if (route.ts[i] == 'C') { - fprintf(fp, "%c %g,%g %g,%g %g,%g", route.ts[i], + fprintf(fp, "%c %g,%g %g,%g %g,%g", route.ts[i], route.ps[i].x, route.ps[i].y, route.ps[i+1].x, route.ps[i+1].y, route.ps[i+2].x, route.ps[i+2].y); @@ -1793,7 +1793,7 @@ void Router::outputInstanceToSVG(std::string instanceName) } else { - fprintf(fp, "%c %g,%g ", route.ts[i], + fprintf(fp, "%c %g,%g ", route.ts[i], route.ps[i].x, route.ps[i].y); } } @@ -1807,7 +1807,7 @@ void Router::outputInstanceToSVG(std::string instanceName) fprintf(fp, "style=\"fill: none; stroke: black; " "stroke-width: 1px;\" />\n"); } - + ++connRefIt; } fprintf(fp, "\n"); @@ -1820,7 +1820,7 @@ void Router::outputInstanceToSVG(std::string instanceName) while (connRefIt != connRefs.end()) { ConnRef *connRef = *connRefIt; - + PolyLine route = connRef->displayRoute(); if (!route.empty()) { @@ -1840,7 +1840,7 @@ void Router::outputInstanceToSVG(std::string instanceName) fprintf(fp, "style=\"fill: none; stroke: black; " "stroke-width: 1px;\" />\n"); } - + ++connRefIt; } fprintf(fp, "\n"); diff --git a/src/libavoid/vpsc.cpp b/src/libavoid/vpsc.cpp index c9a072375..19d360375 100644 --- a/src/libavoid/vpsc.cpp +++ b/src/libavoid/vpsc.cpp @@ -12,12 +12,12 @@ * 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 + * 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * Author(s): Tim Dwyer * @@ -52,11 +52,11 @@ namespace Avoid { static const double ZERO_UPPERBOUND=-1e-10; static const double LAGRANGIAN_TOLERANCE=-1e-4; -IncSolver::IncSolver(vector const &vs, vector const &cs) - : m(cs.size()), - cs(cs), - n(vs.size()), - vs(vs) +IncSolver::IncSolver(vector const &vs, vector const &cs) + : m(cs.size()), + cs(cs), + n(vs.size()), + vs(vs) { for(unsigned i=0;iin.clear(); @@ -232,7 +232,7 @@ bool IncSolver::solve() { #endif } copyResult(); - return bs->size()!=n; + return bs->size()!=n; } /* * incremental version of satisfy that allows refinement after blocks are @@ -244,8 +244,8 @@ bool IncSolver::solve() { * * Note: there is a special case to handle when the most violated constraint * is between two variables in the same block. Then, we must split the block - * over an active constraint between the two variables. We choose the - * constraint with the most negative lagrangian multiplier. + * over an active constraint between the two variables. We choose the + * constraint with the most negative lagrangian multiplier. */ bool IncSolver::satisfy() { #ifdef LIBVPSC_LOGGING @@ -256,8 +256,8 @@ bool IncSolver::satisfy() { //long splitCtr = 0; Constraint* v = NULL; //CBuffer buffer(inactive); - while((v=mostViolated(inactive)) - &&(v->equality || v->slack() < ZERO_UPPERBOUND && !v->active)) + while((v = mostViolated(inactive)) + && (v->equality || ((v->slack() < ZERO_UPPERBOUND) && !v->active))) { COLA_ASSERT(!v->active); Block *lb = v->left->block, *rb = v->right->block; @@ -411,7 +411,7 @@ Constraint* IncSolver::mostViolated(Constraints &l) { Constraint *c=*i; double slack = c->slack(); if(c->equality || slack < minSlack) { - minSlack=slack; + minSlack=slack; v=c; deletePoint=i; if(c->equality) break; @@ -421,7 +421,8 @@ Constraint* IncSolver::mostViolated(Constraints &l) { // move the last element over the deletePoint and resize // downwards. There is always at least 1 element in the // vector because of search. - if(deletePoint != end && (minSlack < ZERO_UPPERBOUND && !v->active || v->equality)) { + // TODO check this logic and add parens: + if((deletePoint != end) && ((minSlack < ZERO_UPPERBOUND) && !v->active || v->equality)) { *deletePoint = l[l.size()-1]; l.resize(l.size()-1); } @@ -457,7 +458,7 @@ Blocks::~Blocks(void) } /* - * returns a list of variables with total ordering determined by the constraint + * returns a list of variables with total ordering determined by the constraint * DAG */ list *Blocks::totalOrder() { @@ -482,7 +483,7 @@ void Blocks::dfsVisit(Variable *v, list *order) { if(!c->right->visited) { dfsVisit(c->right, order); } - } + } #ifdef LIBVPSC_LOGGING ofstream f(LOGFILE,ios::app); f<<" order="<<*v< *order) { * Processes incoming constraints, most violated to least, merging with the * neighbouring (left) block until no more violated constraints are found */ -void Blocks::mergeLeft(Block *r) { +void Blocks::mergeLeft(Block *r) { #ifdef LIBVPSC_LOGGING ofstream f(LOGFILE,ios::app); f<<"mergeLeft called on "<<*r<deleteMinInConstraint(); - Block *l = c->left->block; + Block *l = c->left->block; if (l->in==NULL) l->setUpInConstraints(); double dist = c->right->offset - c->left->offset - c->gap; if (r->vars->size() < l->vars->size()) { @@ -519,22 +520,22 @@ void Blocks::mergeLeft(Block *r) { r->timeStamp=blockTimeCtr; removeBlock(l); c=r->findMinInConstraint(); - } + } #ifdef LIBVPSC_LOGGING f<<"merged "<<*r<setUpOutConstraints(); Constraint *c = l->findMinOutConstraint(); - while (c != NULL && c->slack()<0) { + while (c != NULL && c->slack()<0) { #ifdef LIBVPSC_LOGGING f<<"mergeRight on constraint: "<<*c<mergeOut(r); removeBlock(r); c=l->findMinOutConstraint(); - } + } #ifdef LIBVPSC_LOGGING f<<"merged "<<*l<id << "], blockscale=" << scale << ", despos=" + f << "adding v[" << v->id << "], blockscale=" << scale << ", despos=" << v->desiredPosition << ", ai=" << ai << ", bi=" << bi << ", AB=" << AB << ", AD=" << AD << ", A2=" << A2; #endif @@ -692,12 +693,12 @@ void Block::setUpConstraintHeap(Heap* &h,bool in) { for (Cit j=cs->begin();j!=cs->end();++j) { Constraint *c=*j; c->timeStamp=blockTimeCtr; - if (c->left->block != this && in || c->right->block != this && !in) { + if (((c->left->block != this) && in) || ((c->right->block != this) && !in)) { h->push(c); } } } -} +} Block* Block::merge(Block* b, Constraint* c) { #ifdef LIBVPSC_LOGGING ofstream f(LOGFILE,ios::app); @@ -772,7 +773,7 @@ void Block::mergeIn(Block *b) { f<<" merged heap: "<<*in<findMinOutConstraint(); while (!b->out->empty()) @@ -904,21 +905,21 @@ double Block::compute_dfdv(Variable* const v, Variable* const u) { } // The top level v and r are variables between which we want to find the -// constraint with the smallest lm. +// constraint with the smallest lm. // Similarly, m is initially NULL and is only assigned a value if the next // variable to be visited is r or if a possible min constraint is returned from // a nested call (rather than NULL). // Then, the search for the m with minimum lm occurs as we return from -// the recursion (checking only constraints traversed left-to-right +// the recursion (checking only constraints traversed left-to-right // in order to avoid creating any new violations). // We also do not consider equality constraints as potential split points bool Block::split_path( - Variable* r, - Variable* const v, - Variable* const u, + Variable* r, + Variable* const v, + Variable* const u, Constraint* &m, bool desperation=false - ) + ) { for(Cit it(v->in.begin());it!=v->in.end();++it) { Constraint *c=*it; @@ -963,43 +964,43 @@ bool Block::split_path( } /* Block::Pair Block::compute_dfdv_between( - Variable* r, Variable* const v, Variable* const u, + Variable* r, Variable* const v, Variable* const u, const Direction dir = NONE, bool changedDirection = false) { double dfdv=v->weight*(v->position() - v->desiredPosition); Constraint *m=NULL; for(Cit it(v->in.begin());it!=v->in.end();++it) { Constraint *c=*it; if(canFollowLeft(c,u)) { - if(dir==RIGHT) { - changedDirection = true; + if(dir==RIGHT) { + changedDirection = true; } if(c->left==r) { r=NULL; - if(!c->equality) m=c; + if(!c->equality) m=c; } Pair p=compute_dfdv_between(r,c->left,v, LEFT,changedDirection); dfdv -= c->lm = -p.first; - if(r && p.second) + if(r && p.second) m = p.second; } } for(Cit it(v->out.begin());it!=v->out.end();++it) { Constraint *c=*it; if(canFollowRight(c,u)) { - if(dir==LEFT) { - changedDirection = true; + if(dir==LEFT) { + changedDirection = true; } if(c->right==r) { - r=NULL; - if(!c->equality) m=c; + r=NULL; + if(!c->equality) m=c; } Pair p=compute_dfdv_between(r,c->right,v, RIGHT,changedDirection); dfdv += c->lm = p.first; - if(r && p.second) - m = changedDirection && !c->equality && c->lm < p.second->lm - ? c + if(r && p.second) + m = changedDirection && !c->equality && c->lm < p.second->lm + ? c : p.second; } } @@ -1084,7 +1085,7 @@ Constraint *Block::findMinLMBetween(Variable* const lv, Variable* const rv) { return min_lm; } -// populates block b by traversing the active constraint tree adding variables as they're +// populates block b by traversing the active constraint tree adding variables as they're // visited. Starts from variable v and does not backtrack over variable u. void Block::populateSplitBlock(Block *b, Variable* v, Variable const* u) { b->addVariable(v); @@ -1093,7 +1094,7 @@ void Block::populateSplitBlock(Block *b, Variable* v, Variable const* u) { populateSplitBlock(b, (*c)->left, v); } for (Cit c=v->out.begin();c!=v->out.end();++c) { - if (canFollowRight(*c,u)) + if (canFollowRight(*c,u)) populateSplitBlock(b, (*c)->right, v); } } @@ -1225,7 +1226,7 @@ Constraint::Constraint(Variable *left, Variable *right, double gap, bool equalit //right->in.push_back(this); } Constraint::~Constraint() { - // see constructor: the following is just way too slow. + // see constructor: the following is just way too slow. // Better to create a // new DAG on demand than maintain the lists dynamically. //Constraints::iterator i; @@ -1238,10 +1239,10 @@ Constraint::~Constraint() { //} //right->in.erase(i); } -double Constraint::slack() const { +double Constraint::slack() const { return unsatisfiable ? DBL_MAX - : right->scale * right->position() - - gap - left->scale * left->position(); + : right->scale * right->position() + - gap - left->scale * left->position(); } std::ostream& operator <<(std::ostream &os, const Constraint &c) { @@ -1269,11 +1270,11 @@ std::ostream& operator <<(std::ostream &os, const Constraint &c) bool CompareConstraints::operator() ( Constraint *const &l, Constraint *const &r ) const { - double const sl = + double const sl = l->left->block->timeStamp > l->timeStamp ||l->left->block==l->right->block ?-DBL_MAX:l->slack(); - double const sr = + double const sr = r->left->block->timeStamp > r->timeStamp ||r->left->block==r->right->block ?-DBL_MAX:r->slack(); diff --git a/src/libnr/nr-compose-transform.cpp b/src/libnr/nr-compose-transform.cpp index ad1279f30..6e03faf2f 100644 --- a/src/libnr/nr-compose-transform.cpp +++ b/src/libnr/nr-compose-transform.cpp @@ -19,9 +19,9 @@ /*#ifdef WITH_MMX #ifdef __cplusplus extern "C" { -#endif /* __cplusplus */ -/* fixme: */ -/*int nr_have_mmx (void); +#endif // __cplusplus +/ * fixme: * / +/ *int nr_have_mmx (void); #define NR_PIXOPS_MMX (1 && nr_have_mmx ()) #ifdef __cplusplus } diff --git a/src/live_effects/lpe-extrude.cpp b/src/live_effects/lpe-extrude.cpp index 93ab60fc5..af933eae6 100644 --- a/src/live_effects/lpe-extrude.cpp +++ b/src/live_effects/lpe-extrude.cpp @@ -73,6 +73,7 @@ LPEExtrude::doEffect_pwd2 (Geom::Piecewise > const & pwd2 return pwd2_out; } + default: case 1: { Piecewise > pwd2_out; bool closed_path = are_near(pwd2_in.firstValue(), pwd2_in.lastValue()); diff --git a/src/live_effects/lpe-recursiveskeleton.cpp b/src/live_effects/lpe-recursiveskeleton.cpp index 3cbac5829..50a3bfb6c 100644 --- a/src/live_effects/lpe-recursiveskeleton.cpp +++ b/src/live_effects/lpe-recursiveskeleton.cpp @@ -1,6 +1,6 @@ #define INKSCAPE_LPE_RECURSIVESKELETON_CPP /** \file - * @brief + * @brief * * Inspired by Hofstadter's 'Goedel Escher Bach', chapter V. */ @@ -52,7 +52,6 @@ LPERecursiveSkeleton::doEffect_pwd2 (Geom::Piecewise > co std::vector > > pre_output; double prop_scale = 1.0; - double fuse_tolerance = 0; D2 > patternd2 = make_cuts_independent(pwd2_in); Piecewise x0 = false /*vertical_pattern.get_value()*/ ? Piecewise(patternd2[1]) : Piecewise(patternd2[0]); @@ -95,9 +94,10 @@ LPERecursiveSkeleton::doEffect_pwd2 (Geom::Piecewise > co double scaling = 1; scaling = (uskeleton.domain().extent() - toffset)/pattBndsX->extent(); - + + // TODO investigate why pattWidth is not being used: double pattWidth = pattBndsX->extent() * scaling; - + if (scaling != 1.0) { x*=scaling; } diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp index bcfd0f373..228857ebf 100644 --- a/src/live_effects/lpe-rough-hatches.cpp +++ b/src/live_effects/lpe-rough-hatches.cpp @@ -94,7 +94,7 @@ public: LevelsCrossings(std::vector > const ×, Piecewise > const &f, Piecewise const &dx){ - + for (unsigned i=0; i > +Geom::Piecewise > LPERoughHatches::doEffect_pwd2 (Geom::Piecewise > const & pwd2_in){ //std::cout<<"doEffect_pwd2:\n"; Piecewise > result; - + Piecewise > transformed_pwd2_in = pwd2_in; Point start = pwd2_in.segs.front().at0(); Point end = pwd2_in.segs.back().at1(); @@ -324,11 +324,11 @@ LPERoughHatches::doEffect_pwd2 (Geom::Piecewise > const & Matrix mat(-hatches_dir[Y], hatches_dir[X], hatches_dir[X], hatches_dir[Y],0,0); transformed_pwd2_in = transformed_pwd2_in * mat; transformed_org *= mat; - + std::vector > snakePoints; snakePoints = linearSnake(transformed_pwd2_in, transformed_org); if ( snakePoints.size() > 0 ){ - Piecewise >smthSnake = smoothSnake(snakePoints); + Piecewise >smthSnake = smoothSnake(snakePoints); smthSnake = smthSnake*mat.inverse(); if (do_bend.get_value()){ smthSnake = smthSnake*bend_mat; @@ -354,7 +354,7 @@ LPERoughHatches::generateLevels(Interval const &domain, double x_org){ while (x < domain.max()){ result.push_back(x); double rdm = 1; - if (dist_rdm.get_value() != 0) + if (dist_rdm.get_value() != 0) rdm = 1.+ double((2*dist_rdm - dist_rdm.get_value()))/100.; x+= step*rdm; step*=scale;//(1.+double(growth)); @@ -366,7 +366,7 @@ LPERoughHatches::generateLevels(Interval const &domain, double x_org){ //------------------------------------------------------- // Walk through the intersections to create linear hatches //------------------------------------------------------- -std::vector > +std::vector > LPERoughHatches::linearSnake(Piecewise > const &f, Point const &org){ //std::cout<<"linearSnake:\n"; @@ -401,14 +401,14 @@ LPERoughHatches::linearSnake(Piecewise > const &f, Point const &org){ unsigned i,j; lscs.findFirstUnused(i,j); - + std::vector result_component; int n = int((range->min()-org[X])/hatch_dist); - - while ( i < lscs.size() ){ + + while ( i < lscs.size() ){ int dir = 0; //switch orientation of first segment according to starting point. - if (i % 2 == n%2 && j < lscs[i].size()-1 && !lscs[i][j].used){ + if ((i % 2 == n % 2) && ((j + 1) < lscs[i].size()) && !lscs[i][j].used){ j += 1; dir = 2; } @@ -428,7 +428,7 @@ LPERoughHatches::linearSnake(Piecewise > const &f, Point const &org){ //------------------------------------------------------- // Smooth the linear hatches according to params... //------------------------------------------------------- -Piecewise > +Piecewise > LPERoughHatches::smoothSnake(std::vector > const &linearSnake){ Piecewise > result; @@ -444,7 +444,7 @@ LPERoughHatches::smoothSnake(std::vector > const &linearSnake Geom::Path res_comp_top(last_pt); Geom::Path res_comp_bot(last_pt); unsigned i=1; - //bool is_top = true;//Inversion here; due to downward y? + //bool is_top = true;//Inversion here; due to downward y? bool is_top = ( linearSnake[comp][0][Y] < linearSnake[comp][1][Y] ); while( i+1 > const &linearSnake double scale_in = (is_top ? scale_tf : scale_bf ); double scale_out = (is_top ? scale_tb : scale_bb ); if (is_top){ - if (top_edge_variation.get_value() != 0) + if (top_edge_variation.get_value() != 0) new_pt[Y] += double(top_edge_variation)-top_edge_variation.get_value()/2.; - if (top_tgt_variation.get_value() != 0) + if (top_tgt_variation.get_value() != 0) new_pt[X] += double(top_tgt_variation)-top_tgt_variation.get_value()/2.; if (top_smth_variation.get_value() != 0) { scale_in*=(100.-double(top_smth_variation))/100.; scale_out*=(100.-double(top_smth_variation))/100.; } }else{ - if (bot_edge_variation.get_value() != 0) + if (bot_edge_variation.get_value() != 0) new_pt[Y] += double(bot_edge_variation)-bot_edge_variation.get_value()/2.; - if (bot_tgt_variation.get_value() != 0) + if (bot_tgt_variation.get_value() != 0) new_pt[X] += double(bot_tgt_variation)-bot_tgt_variation.get_value()/2.; if (bot_smth_variation.get_value() != 0) { scale_in*=(100.-double(bot_smth_variation))/100.; @@ -474,7 +474,7 @@ LPERoughHatches::smoothSnake(std::vector > const &linearSnake } Point new_hdle_in = new_pt + (pt0-pt1) * (scale_in /2.); Point new_hdle_out = new_pt - (pt0-pt1) * (scale_out/2.); - + if ( fat_output.get_value() ){ //double scaled_width = double((is_top ? stroke_width_top : stroke_width_bot))/(pt1[X]-pt0[X]); double scaled_width = 1./(pt1[X]-pt0[X]); @@ -494,7 +494,7 @@ LPERoughHatches::smoothSnake(std::vector > const &linearSnake //TODO: find a good way to handle limit cases (small smthness, large stroke). //if (inside_hdle_in[X] > inside[X]) inside_hdle_in = inside; //if (inside_hdle_out[X] < inside[X]) inside_hdle_out = inside; - + if (is_top){ res_comp_top.appendNew(last_top_hdle,new_hdle_in,new_pt); res_comp_bot.appendNew(last_bot_hdle,inside_hdle_in,inside); @@ -509,7 +509,7 @@ LPERoughHatches::smoothSnake(std::vector > const &linearSnake }else{ res_comp.appendNew(last_hdle,new_hdle_in,new_pt); } - + last_hdle = new_hdle_out; i+=2; is_top = !is_top; @@ -525,7 +525,7 @@ LPERoughHatches::smoothSnake(std::vector > const &linearSnake if ( fat_output.get_value() ){ res_comp = res_comp_bot; res_comp.append(res_comp_top.reverse(),Geom::Path::STITCH_DISCONTINUOUS); - } + } result.concat(res_comp.toPwSb()); } } diff --git a/src/live_effects/lpe-ruler.cpp b/src/live_effects/lpe-ruler.cpp index 80970fd8a..35c9ea695 100644 --- a/src/live_effects/lpe-ruler.cpp +++ b/src/live_effects/lpe-ruler.cpp @@ -40,8 +40,8 @@ static const Util::EnumDataConverter BorderMarkTypeConverter(Bor LPERuler::LPERuler(LivePathEffectObject *lpeobject) : Effect(lpeobject), - unit(_("Unit"), _("Unit"), "unit", &wr, this), mark_distance(_("Mark distance"), _("Distance between successive ruler marks"), "mark_distance", &wr, this, 20.0), + unit(_("Unit"), _("Unit"), "unit", &wr, this), mark_length(_("Major length"), _("Length of major ruler marks"), "mark_length", &wr, this, 14.0), minor_mark_length(_("Minor length"), _("Length of minor ruler marks"), "minor_mark_length", &wr, this, 7.0), major_mark_steps(_("Major steps"), _("Draw a major mark every ... steps"), "major_mark_steps", &wr, this, 5), diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index a8ea15744..57d583ba6 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -32,9 +32,9 @@ Parameter::Parameter( const Glib::ustring& label, const Glib::ustring& tip, param_wr(wr), param_label(label), oncanvas_editable(false), + widget_is_visible(true), param_tooltip(tip), - param_effect(effect), - widget_is_visible(true) + param_effect(effect) { } diff --git a/src/print.cpp b/src/print.cpp index 044dffe34..ed9b8d19c 100644 --- a/src/print.cpp +++ b/src/print.cpp @@ -130,6 +130,7 @@ sp_print_document(Gtk::Window& parentWindow, SPDocument *doc) SPItem *base = SP_ITEM(sp_document_root(doc)); NRArena *arena = NRArena::create(); unsigned int dkey = sp_item_display_key_new(1); + // TODO investigate why we are grabbing root and then ignoring it. NRArenaItem *root = sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY); // Run print dialog diff --git a/src/sp-conn-end.cpp b/src/sp-conn-end.cpp index 52914ee9e..2287a182d 100644 --- a/src/sp-conn-end.cpp +++ b/src/sp-conn-end.cpp @@ -46,7 +46,7 @@ static bool try_get_intersect_point_with_item_recursive(Geom::PathVector& conn_p // if this is a group... if (SP_IS_GROUP(item)) { SPGroup* group = SP_GROUP(item); - + // consider all first-order children double child_pos = std::numeric_limits::max(); for (GSList const* i = sp_item_group_item_list(group); i != NULL; i = i->next) { @@ -93,9 +93,9 @@ static bool try_get_intersect_point_with_item_recursive(Geom::PathVector& conn_p // The transforms given should be to a common ancestor of both the path and item. // static bool try_get_intersect_point_with_item(SPPath* conn, SPItem* item, - const Geom::Matrix& item_transform, const Geom::Matrix& conn_transform, + const Geom::Matrix& item_transform, const Geom::Matrix& conn_transform, const bool at_start, double& intersect_pos) { - + // Copy the curve and apply transformations up to common ancestor. SPCurve* conn_curve = conn->curve->copy(); conn_curve->transform(conn_transform); @@ -130,7 +130,7 @@ static bool try_get_intersect_point_with_item(SPPath* conn, SPItem* item, static void -sp_conn_get_route_and_redraw(SPPath *const path, +sp_conn_get_route_and_redraw(SPPath *const path, const bool updatePathRepr = true) { // Get the new route around obstacles. @@ -138,7 +138,7 @@ sp_conn_get_route_and_redraw(SPPath *const path, if (!rerouted) { return; } - + SPItem *h2attItem[2]; path->connEndPair.getAttachedItems(h2attItem); @@ -146,7 +146,7 @@ sp_conn_get_route_and_redraw(SPPath *const path, SPObject const *const ancestor = get_nearest_common_ancestor(path_item, h2attItem); Geom::Matrix const path2anc(i2anc_affine(path_item, ancestor)); - // Set sensible values incase there the connector ends are not + // Set sensible values incase there the connector ends are not // attached to any shapes. Geom::PathVector conn_pv = path->curve->get_pathvector(); double endPos[2] = { 0, conn_pv[0].size() }; @@ -241,7 +241,7 @@ sp_conn_end_detach(SPObject *const owner, unsigned const handle_ix) } void -SPConnEnd::setAttacherHref(gchar const *value, SPPath* path) +SPConnEnd::setAttacherHref(gchar const *value, SPPath* /*path*/) { if ( value && href && ( strcmp(value, href) == 0 ) ) { /* No change, do nothing. */ @@ -293,7 +293,7 @@ SPConnEnd::setAttacherHref(gchar const *value, SPPath* path) } } // Check to see if the connection point changed and update it. - // + // if ( !value_strarray[1] ) { @@ -353,12 +353,12 @@ SPConnEnd::setAttacherHref(gchar const *value, SPPath* path) validRef = false; } } - + if ( changed ) { // We still have to verify that the reference to the // connection point is a valid one. - + // Get the item the connector is attached to SPItem* item = ref.getObject(); if ( item && !item->avoidRef->isValidConnPointId( type, id ) ) @@ -370,7 +370,8 @@ SPConnEnd::setAttacherHref(gchar const *value, SPPath* path) // Update the connector if (path->connEndPair.isAutoRoutingConn()) { path->connEndPair.tellLibavoidNewEndpoints(); - }*/ + } +*/ } if ( !validRef ) diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 47720c5d6..9b72a4157 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -304,6 +304,7 @@ static void sp_namedview_release(SPObject *object) static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *value) { SPNamedView *nv = SP_NAMEDVIEW(object); + // TODO investigate why we grab this and then never use it SPUnit const &px = sp_unit_get_by_id(SP_UNIT_PX); switch (key) { diff --git a/src/spray-context.cpp b/src/spray-context.cpp index 1c050ea06..b70e16467 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -6,7 +6,7 @@ * Authors: * Pierre-Antoine MARC * Pierre CACLIN - * Aurel-Aimé MARMION + * Aurel-Aimé MARMION * Julien LERAY * Benoît LAVORATA * Vincent MONTAGNE @@ -74,7 +74,7 @@ #include "display/canvas-arena.h" #include "display/curve.h" #include "livarot/Shape.h" -#include <2geom/isnan.h> +#include <2geom/isnan.h> #include <2geom/transforms.h> #include "preferences.h" #include "style.h" @@ -104,7 +104,7 @@ static void sp_spray_context_setup(SPEventContext *ec); static void sp_spray_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val); static gint sp_spray_context_root_handler(SPEventContext *ec, GdkEvent *event); -static SPEventContextClass *parent_class; +static SPEventContextClass *parent_class = 0; @@ -143,8 +143,7 @@ double NormalDistribution(double mu,double sigma) //Fin de la création de NormalDistribution -GtkType -sp_spray_context_get_type(void) +GtkType sp_spray_context_get_type(void) { static GType type = 0; if (!type) { @@ -163,8 +162,7 @@ sp_spray_context_get_type(void) return type; } -static void -sp_spray_context_class_init(SPSprayContextClass *klass) +static void sp_spray_context_class_init(SPSprayContextClass *klass) { GObjectClass *object_class = (GObjectClass *) klass; SPEventContextClass *event_context_class = (SPEventContextClass *) klass; @@ -177,9 +175,9 @@ sp_spray_context_class_init(SPSprayContextClass *klass) event_context_class->set = sp_spray_context_set; event_context_class->root_handler = sp_spray_context_root_handler; } + /*Method to rotate items*/ -void -sp_spray_rotate_rel(Geom::Point c,SPDesktop *desktop,SPItem *item, Geom::Rotate const &rotation) +void sp_spray_rotate_rel(Geom::Point c,SPDesktop */*desktop*/,SPItem *item, Geom::Rotate const &rotation) { Geom::Point center = c; @@ -197,23 +195,23 @@ sp_spray_rotate_rel(Geom::Point c,SPDesktop *desktop,SPItem *item, Geom::Rotate item->updateRepr(); } } + /*Method to scale items*/ -void -sp_spray_scale_rel (Geom::Point c, SPDesktop *desktop, SPItem *item, Geom::Scale const &scale) +void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Scale const &scale) { - Geom::Translate const s(c); + Geom::Translate const s(c); + - sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * s.inverse() * scale * s ); sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform); } -static void -sp_spray_context_init(SPSprayContext *tc) -{ + +static void sp_spray_context_init(SPSprayContext *tc) +{ SPEventContext *event_context = SP_EVENT_CONTEXT(tc); - + event_context->cursor_shape = cursor_spray_xpm; @@ -247,8 +245,7 @@ sp_spray_context_init(SPSprayContext *tc) new (&tc->style_set_connection) sigc::connection(); } -static void -sp_spray_context_dispose(GObject *object) +static void sp_spray_context_dispose(GObject *object) { SPSprayContext *tc = SP_SPRAY_CONTEXT(object); @@ -267,7 +264,7 @@ sp_spray_context_dispose(GObject *object) G_OBJECT_CLASS(parent_class)->dispose(object); } -bool is_transform_modes (gint mode) +bool is_transform_modes(gint mode) { return (mode == SPRAY_MODE_COPY || mode == SPRAY_MODE_CLONE || @@ -275,8 +272,7 @@ bool is_transform_modes (gint mode) mode == SPRAY_OPTION); } -void -sp_spray_update_cursor (SPSprayContext *tc, bool with_shift) +void sp_spray_update_cursor(SPSprayContext *tc, bool /*with_shift*/) { SPEventContext *event_context = SP_EVENT_CONTEXT(tc); SPDesktop *desktop = event_context->desktop; @@ -309,8 +305,7 @@ sp_spray_update_cursor (SPSprayContext *tc, bool with_shift) g_free(sel_message); } -static void -sp_spray_context_setup(SPEventContext *ec) +static void sp_spray_context_setup(SPEventContext *ec) { SPSprayContext *tc = SP_SPRAY_CONTEXT(ec); @@ -338,7 +333,7 @@ sp_spray_context_setup(SPEventContext *ec) tc->_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack()); - sp_event_context_read(ec, "distrib"); + sp_event_context_read(ec, "distrib"); sp_event_context_read(ec, "width"); sp_event_context_read(ec, "ratio"); sp_event_context_read(ec, "tilt"); @@ -372,8 +367,7 @@ sp_spray_context_setup(SPEventContext *ec) } } -static void -sp_spray_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val) +static void sp_spray_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val) { SPSprayContext *tc = SP_SPRAY_CONTEXT(ec); Glib::ustring path = val->getEntryName(); @@ -398,7 +392,7 @@ sp_spray_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val) } else if (path == "rot_max") { tc->rot_max = CLAMP(val->getDouble(0), 0, 10.0); } else if (path == "scale_min") { - tc->scale_min = CLAMP(val->getDouble(1.0), 0, 10.0); + tc->scale_min = CLAMP(val->getDouble(1.0), 0, 10.0); } else if (path == "scale_max") { tc->scale_max = CLAMP(val->getDouble(1.0), 0, 10.0); } else if (path == "mean") { @@ -418,8 +412,7 @@ sp_spray_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val) } } -static void -sp_spray_extinput(SPSprayContext *tc, GdkEvent *event) +static void sp_spray_extinput(SPSprayContext *tc, GdkEvent *event) { if (gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &tc->pressure)) tc->pressure = CLAMP (tc->pressure, TC_MIN_PRESSURE, TC_MAX_PRESSURE); @@ -427,8 +420,7 @@ sp_spray_extinput(SPSprayContext *tc, GdkEvent *event) tc->pressure = TC_DEFAULT_PRESSURE; } -double -get_dilate_radius (SPSprayContext *tc) +double get_dilate_radius(SPSprayContext *tc) { return 250 * tc->width/SP_EVENT_CONTEXT(tc)->desktop->current_zoom(); @@ -436,8 +428,7 @@ get_dilate_radius (SPSprayContext *tc) } -double -get_path_force (SPSprayContext *tc) +double get_path_force(SPSprayContext *tc) { double force = 8 * (tc->usepressure? tc->pressure : TC_DEFAULT_PRESSURE) /sqrt(SP_EVENT_CONTEXT(tc)->desktop->current_zoom()); @@ -447,33 +438,28 @@ get_path_force (SPSprayContext *tc) return force * tc->force; } -double -get_path_mean (SPSprayContext *tc) +double get_path_mean(SPSprayContext *tc) { return tc->mean; } -double -get_path_standard_deviation (SPSprayContext *tc) +double get_path_standard_deviation(SPSprayContext *tc) { return tc->standard_deviation; } -double -get_move_force (SPSprayContext *tc) +double get_move_force(SPSprayContext *tc) { double force = (tc->usepressure? tc->pressure : TC_DEFAULT_PRESSURE); return force * tc->force; } -double -get_move_mean (SPSprayContext *tc) +double get_move_mean(SPSprayContext *tc) { return tc->mean; } -double -get_move_standard_deviation (SPSprayContext *tc) +double get_move_standard_deviation(SPSprayContext *tc) { return tc->standard_deviation; } @@ -511,8 +497,26 @@ while(!((r_temp>=0)&&(r_temp<=1))) -bool -sp_spray_dilate_recursive (SPDesktop *desktop, Inkscape::Selection *selection, SPItem *item, Geom::Point p, Geom::Point vector, gint mode, double radius, double force, double population, double &scale, double scale_min, double scale_max, bool reverse, double mean, double standard_deviation, double ratio,double tilt, double rot_min, double rot_max, gint _distrib ) +bool sp_spray_dilate_recursive(SPDesktop *desktop, + Inkscape::Selection *selection, + SPItem *item, + Geom::Point p, + Geom::Point /*vector*/, + gint mode, + double radius, + double /*force*/, + double population, + double &scale, + double scale_min, + double scale_max, + bool /*reverse*/, + double mean, + double standard_deviation, + double ratio, + double tilt, + double rot_min, + double rot_max, + gint _distrib ) { @@ -551,13 +555,13 @@ sp_spray_dilate_recursive (SPDesktop *desktop, Inkscape::Selection *selection, S Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item)); if (a) { - double dr; double dp; + double dr; double dp; random_position(dr,dp,mean,standard_deviation,_distrib); dr=dr*radius; double _fid = g_random_double_range(0,1); SPItem *item_copied; - double angle = g_random_double_range(rot_min, rot_max); - double _scale = g_random_double_range(scale_min, scale_max); + double angle = g_random_double_range(rot_min, rot_max); + double _scale = g_random_double_range(scale_min, scale_max); if(_fid<=population) { // duplicate @@ -571,17 +575,17 @@ sp_spray_dilate_recursive (SPDesktop *desktop, Inkscape::Selection *selection, S SPObject *new_obj = doc->getObjectByRepr(copy); item_copied = (SPItem *) new_obj; //convertion object->item Geom::Point center=item->getCenter(); - sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(_scale,_scale)); - sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(scale,scale)); - - sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle)); + sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(_scale,_scale)); + sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(scale,scale)); + + sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle)); Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio),-sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint());//Move the cursor p sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y])); - - - + + + did = true; } } @@ -623,8 +627,8 @@ sp_spray_dilate_recursive (SPDesktop *desktop, Inkscape::Selection *selection, S random_position(dr,dp,mean,standard_deviation,_distrib); dr=dr*radius; double _fid = g_random_double_range(0,1); - double angle = (g_random_double_range(rot_min, rot_max)); - double _scale = g_random_double_range(scale_min, scale_max); + double angle = (g_random_double_range(rot_min, rot_max)); + double _scale = g_random_double_range(scale_min, scale_max); if (i==2) { Inkscape::XML::Node *copy1 = old_repr->duplicate(xml_doc); parent->appendChild(copy1); @@ -640,11 +644,11 @@ sp_spray_dilate_recursive (SPDesktop *desktop, Inkscape::Selection *selection, S parent->appendChild(copy2); SPObject *new_obj2 = doc->getObjectByRepr(copy2); item_copied = (SPItem *) new_obj2; - - Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio),-sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint());//Move around the cursor + + Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio),-sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint());//Move around the cursor Geom::Point center=Pere->getCenter(); - sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(_scale,_scale)); + sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(_scale,_scale)); sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(scale,scale)); sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle)); sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y])); @@ -661,10 +665,10 @@ sp_spray_dilate_recursive (SPDesktop *desktop, Inkscape::Selection *selection, S } } else if (mode == SPRAY_MODE_CLONE) { - + Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item)); if (a) { - double dr; double dp; + double dr; double dp; random_position(dr,dp,mean,standard_deviation,_distrib); dr=dr*radius; double _fid = g_random_double_range(0,1); @@ -673,7 +677,7 @@ sp_spray_dilate_recursive (SPDesktop *desktop, Inkscape::Selection *selection, S if(_fid<=population) { - SPItem *item_copied; + SPItem *item_copied; SPDocument *doc = SP_OBJECT_DOCUMENT(item); Inkscape::XML::Document* xml_doc = sp_document_repr_doc(doc); Inkscape::XML::Node *old_repr = SP_OBJECT_REPR(item); @@ -683,33 +687,43 @@ sp_spray_dilate_recursive (SPDesktop *desktop, Inkscape::Selection *selection, S Inkscape::XML::Node *clone = xml_doc->createElement("svg:use"); parent->appendChild(clone); //Ajout du clone à la liste d'enfants du père (selection initiale clone->setAttribute("xlink:href", g_strdup_printf("#%s", old_repr->attribute("id")), false); //Génère le lien entre les attributs du père et du fils - - SPObject *clone_object = doc->getObjectByRepr(clone); + + SPObject *clone_object = doc->getObjectByRepr(clone); item_copied = (SPItem *) clone_object;//conversion object->item Geom::Point center=item->getCenter(); - sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(_scale,_scale)); + sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(_scale,_scale)); sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(scale,scale)); - sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle)); + sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle)); Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio),-sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint()); - sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y])); + sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y])); Inkscape::GC::release(clone); did = true; } }} return did; - + } -bool -sp_spray_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, - guint32 fill_goal, bool do_fill, - guint32 stroke_goal, bool do_stroke, - float opacity_goal, bool do_opacity, - bool do_blur, bool reverse, - Geom::Point p, double radius, double force, - bool do_h, bool do_s, bool do_l, bool do_o) +bool sp_spray_color_recursive(guint /*mode*/, + SPItem */*item*/, + SPItem */*item_at_point*/, + guint32 /*fill_goal*/, + bool /*do_fill*/, + guint32 /*stroke_goal*/, + bool /*do_stroke*/, + float /*opacity_goal*/, + bool /*do_opacity*/, + bool /*do_blur*/, + bool /*reverse*/, + Geom::Point /*p*/, + double /*radius*/, + double /*force*/, + bool /*do_h*/, + bool /*do_s*/, + bool /*do_l*/, + bool /*do_o*/) { bool did = false; @@ -717,8 +731,7 @@ sp_spray_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, } -bool -sp_spray_dilate (SPSprayContext *tc, Geom::Point event_p, Geom::Point p, Geom::Point vector, bool reverse) +bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::Point p, Geom::Point vector, bool reverse) { Inkscape::Selection *selection = sp_desktop_selection(SP_EVENT_CONTEXT(tc)->desktop); SPDesktop *desktop = SP_EVENT_CONTEXT(tc)->desktop; @@ -815,8 +828,7 @@ sp_spray_dilate (SPSprayContext *tc, Geom::Point event_p, Geom::Point p, Geom::P return did; } -void -sp_spray_update_area (SPSprayContext *tc) +void sp_spray_update_area(SPSprayContext *tc) { double radius = get_dilate_radius(tc); Geom::Matrix const sm ( Geom::Scale(radius/(1-tc->ratio), radius/(1+tc->ratio)) ); @@ -824,8 +836,7 @@ sp_spray_update_area (SPSprayContext *tc) sp_canvas_item_show(tc->dilate_area); } -void -sp_spray_switch_mode (SPSprayContext *tc, gint mode, bool with_shift) +void sp_spray_switch_mode(SPSprayContext *tc, gint mode, bool with_shift) { SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue ("spray_tool_mode", mode); //sélectionne le bouton numéro "mode" // need to set explicitly, because the prefs may not have changed by the previous @@ -833,8 +844,7 @@ sp_spray_switch_mode (SPSprayContext *tc, gint mode, bool with_shift) sp_spray_update_cursor (tc, with_shift); } -void -sp_spray_switch_mode_temporarily (SPSprayContext *tc, gint mode, bool with_shift) +void sp_spray_switch_mode_temporarily(SPSprayContext *tc, gint mode, bool with_shift) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); // Juggling about so that prefs have the old value but tc->mode and the button show new mode: @@ -847,8 +857,7 @@ sp_spray_switch_mode_temporarily (SPSprayContext *tc, gint mode, bool with_shift sp_spray_update_cursor (tc, with_shift); } -gint -sp_spray_context_root_handler(SPEventContext *event_context, +gint sp_spray_context_root_handler(SPEventContext *event_context, GdkEvent *event) { SPSprayContext *tc = SP_SPRAY_CONTEXT(event_context); @@ -922,7 +931,7 @@ sp_spray_context_root_handler(SPEventContext *event_context, sp_spray_dilate (tc, motion_w, motion_doc, motion_doc - tc->last_push, event->button.state & GDK_SHIFT_MASK? true : false); //tc->last_push = motion_doc; tc->has_dilated = true; - + // it's slow, so prevent clogging up with events gobble_motion_events(GDK_BUTTON1_MASK); return TRUE; @@ -942,7 +951,7 @@ sp_spray_context_root_handler(SPEventContext *event_context, Geom::Point const scroll_w(event->button.x,event->button.y); Geom::Point const scroll_dt = desktop->point();; Geom::Point motion_doc(desktop->dt2doc(scroll_dt)); - switch (event->scroll.direction) + switch (event->scroll.direction) { case GDK_SCROLL_UP: { @@ -957,16 +966,16 @@ sp_spray_context_root_handler(SPEventContext *event_context, tc->is_dilating = true; tc->has_dilated = false; if(tc->is_dilating && !event_context->space_panning) - + sp_spray_dilate (tc, scroll_w, desktop->dt2doc(scroll_dt), Geom::Point(0,0),false); - + tc->has_dilated=true; tc->population=temp; desktop->setToolboxAdjustmentValue ("population", tc->population * 100); - + ret = TRUE; } break; @@ -1042,17 +1051,17 @@ case GDK_SCROLL_LEFT: case GDK_j: if (MOD__SHIFT_ONLY) { sp_spray_switch_mode(tc, SPRAY_MODE_COPY, MOD__SHIFT); ret = TRUE; - } + } case GDK_J: if (MOD__SHIFT_ONLY) { sp_spray_switch_mode(tc, SPRAY_MODE_COPY, MOD__SHIFT); ret = TRUE; } - + break; case GDK_m: case GDK_M: case GDK_0: - + break; case GDK_i: case GDK_I: @@ -1065,12 +1074,12 @@ break; ret = TRUE; } break; - + case GDK_l: if (MOD__SHIFT_ONLY) { sp_spray_switch_mode(tc, SPRAY_MODE_CLONE, MOD__SHIFT); ret = TRUE; } - + case GDK_L: if (MOD__SHIFT_ONLY) { sp_spray_switch_mode(tc, SPRAY_MODE_CLONE, MOD__SHIFT); diff --git a/src/svg/svg-color.cpp b/src/svg/svg-color.cpp index 46779311e..ff5a6c2d3 100644 --- a/src/svg/svg-color.cpp +++ b/src/svg/svg-color.cpp @@ -351,9 +351,9 @@ sp_svg_read_color(gchar const *str, gchar const **end_ptr, guint32 dfl) * this check wrapper. */ gchar const *end = str; guint32 const ret = internal_sp_svg_read_color(str, &end, dfl); - assert(ret == dfl && end == str + assert(((ret == dfl) && (end == str)) || (((ret & 0xff) == 0) - && str < end)); + && (str < end))); if (str < end) { gchar *buf = (gchar *) g_malloc(end + 1 - str); memcpy(buf, str, end - str); diff --git a/src/svg/svg-length.cpp b/src/svg/svg-length.cpp index 942f74d46..94f1cf312 100644 --- a/src/svg/svg-length.cpp +++ b/src/svg/svg-length.cpp @@ -64,6 +64,7 @@ unsigned int sp_svg_number_read_d(gchar const *str, double *val) return 1; } +// TODO must add a buffer length parameter for safety: static unsigned int sp_svg_number_write_ui(gchar *buf, unsigned int val) { unsigned int i = 0; diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp index f9db265d6..60cab06a2 100644 --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@ -31,11 +31,15 @@ -static void -draw_page (GtkPrintOperation *operation, - GtkPrintContext *context, - gint /*page_nr*/, - gpointer user_data) +static void draw_page( +#ifdef WIN32 + GtkPrintOperation *operation, +#else + GtkPrintOperation *, +#endif + GtkPrintContext *context, + gint /*page_nr*/, + gpointer user_data) { struct workaround_gtkmm *junk = (struct workaround_gtkmm*)user_data; //printf("%s %d\n",__FUNCTION__, page_nr); diff --git a/src/ui/dialog/spray-option.cpp b/src/ui/dialog/spray-option.cpp index ec83b07cd..a9e037381 100644 --- a/src/ui/dialog/spray-option.cpp +++ b/src/ui/dialog/spray-option.cpp @@ -14,11 +14,11 @@ #include "graphlayout/graphlayout.h" #include "inkscape.h" #include "macros.h" -#include "node-context.h" +#include "node-context.h" #include "preferences.h" #include "removeoverlap/removeoverlap.h" #include "selection.h" -#include "shape-editor.h" +#include "shape-editor.h" #include "sp-flowtext.h" #include "sp-item-transform.h" #include "sp-text.h" @@ -43,21 +43,22 @@ namespace Dialog { class Action { public: Action(const Glib::ustring &id, - const Glib::ustring &tiptext, - guint row, guint column, + const Glib::ustring &/*tiptext*/, + guint /*row*/, + guint /*column*/, Gtk::Table &parent, - Gtk::Tooltips &tooltips, + Gtk::Tooltips &/*tooltips*/, SprayOptionClass &dialog): _dialog(dialog), _id(id), _parent(parent) {} - + virtual ~Action(){} virtual void on_button_click(){} SprayOptionClass &_dialog; - + private : - + Glib::ustring _id; Gtk::Table &_parent; }; @@ -85,7 +86,7 @@ public: dialog._Table().set_col_spacings(3); double increm = ((double)_max - (double)_min)/10; - double val_ini = ((double)_max + (double)_min)/2; + double val_ini = ((double)_max + (double)_min)/2; _Gap.set_digits(1); _Gap.set_size_request(60, -1); _Gap.set_increments(increm , 0); @@ -102,14 +103,14 @@ public: virtual void on_button_click(){ if (!_dialog.getDesktop()) return; - + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - + prefs->setDouble(_pref_path, SP_VERB_CONTEXT_SPRAY); - + double const Gap = _Gap.get_value(); - - + + prefs->setDouble(_pref_path, Gap); sp_document_done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_CONTEXT_SPRAY, @@ -117,7 +118,7 @@ public: } -}; +}; class ActionF : public Action { private: @@ -143,7 +144,7 @@ public: { dialog.F_Table().set_col_spacings(3); - _Label.set_label(id); + _Label.set_label(id); _Gap1.set_digits(1); _Gap1.set_size_request(60, -1); @@ -152,7 +153,7 @@ public: _Gap1.set_value(1); dialog.tooltips().set_tip(_Gap1, _("Minimum")); - + _Label1.set_label(Q_("Min")); _Gap2.set_digits(1); @@ -162,11 +163,11 @@ public: _Gap2.set_value(1); dialog.tooltips().set_tip(_Gap2, _("Maximum")); - + _Label2.set_label(_("Max:")); - + _Gap1.signal_changed().connect(sigc::mem_fun(*this, &ActionF::on_button_click)); - _Gap2.signal_changed().connect(sigc::mem_fun(*this, &ActionF::on_button_click)); + _Gap2.signal_changed().connect(sigc::mem_fun(*this, &ActionF::on_button_click)); dialog.F_Table().attach(_Label, column, column+1, row, row+1, Gtk::FILL, Gtk::FILL); dialog.F_Table().attach(_Label1, column+1, column+2, row, row+1, Gtk::FILL, Gtk::FILL); @@ -178,15 +179,15 @@ public: virtual void on_button_click(){ if (!_dialog.getDesktop()) return; - + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - + prefs->setDouble(_pref1_path, SP_VERB_CONTEXT_SPRAY); prefs->setDouble(_pref2_path, SP_VERB_CONTEXT_SPRAY); - + double const Gap1 = _Gap1.get_value(); double const Gap2 = _Gap2.get_value(); - + prefs->setDouble(_pref1_path, Gap1); prefs->setDouble(_pref2_path, Gap2); @@ -195,21 +196,21 @@ public: } -}; +}; void SprayOptionClass::combo_action() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); cout<<"combo.get_active_row_number = "<<_combo.get_active_row_number()<setInt("/tools/spray/distribution", distrib); - + sp_document_done(sp_desktop_document(this->getDesktop()), SP_VERB_CONTEXT_SPRAY, - _("Remove overlaps")); + _("Remove overlaps")); } @@ -217,11 +218,9 @@ void SprayOptionClass::combo_action() { void SprayOptionClass::action() { - int r=1; - for (list::iterator it = _actionList.begin(); - it != _actionList.end(); - it ++) + for (list::iterator it = _actionList.begin(); it != _actionList.end(); ++it) { (*it)->on_button_click(); + } combo_action(); } @@ -242,16 +241,33 @@ void on_selection_changed(Inkscape::Application */*inkscape*/, Inkscape::Selecti SprayOptionClass::SprayOptionClass() : UI::Widget::Panel ("", "/dialogs/spray", SP_VERB_DIALOG_SPRAY_OPTION), + _actionList(), _distributionFrame(Q_("sprayOptions|Distribution")), _Frame(Q_("sprayOptions|Cursor Options")), _FFrame(Q_("sprayOptions|Random Options")), + _distributionTable(), _gaussianTable(1, 5, false), _ETable(3,2,false), _FTable(2,5,false), + _anchorBox(), + _unifBox(), + _gaussianBox(), + _HBox(), + _FHBox(), + _BoutonBox(), + _distributionBox(), + _VBox(), + _FVBox(), + _ActionBox(), + _anchorLabel(Q_("sprayOptions|Distribution:")), _unifLabel(Q_("sprayOptions|Uniform")), _gaussLabel(Q_("sprayOptions|Gaussian")), - _anchorLabel(Q_("sprayOptions|Distribution:")) - + _Label(), + _FLabel(), + _unif(), + _gauss(), + _combo(), + _tooltips() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -259,7 +275,7 @@ SprayOptionClass::SprayOptionClass() _combo.append_text(Q_("sprayOptions|Uniform")); _combo.append_text(Q_("sprayOptions|Gaussian")); - + _combo.set_active(prefs->getInt("/tools/spray/distribution", 1)); _combo.signal_changed().connect(sigc::mem_fun(*this, &SprayOptionClass::combo_action)); @@ -281,7 +297,7 @@ SprayOptionClass::SprayOptionClass() //Implementation dans la Vbox Cursor _FVBox.pack_start(_FHBox); - _FFrame.add(_FVBox); + _FFrame.add(_FVBox); //Hbox Cursor addEButton(Q_("sprayOptions|Ratio:") ,_("Eccentricity of the ellipse"), 0, 0, 0, 1,"/tools/spray/ratio"); @@ -297,26 +313,26 @@ SprayOptionClass::SprayOptionClass() Gtk::Box *contents = _getContents(); contents->set_spacing(4); - - - + + + // Crée dans l'ordre suivant les différentes Frames (cadres de réglages) contents->pack_start(_distributionFrame, true, true); - contents->pack_start(_FFrame, true, true); + contents->pack_start(_FFrame, true, true); contents->pack_start(_Frame, true, true); - - + + // Connect to the global selection change, to invalidate cached randomize_bbox g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (on_selection_changed), this); randomize_bbox = Geom::OptRect(); show_all_children(); - - + + } @@ -342,7 +358,7 @@ void SprayOptionClass::addEButton(const Glib::ustring &id, const Glib::ustring &tiptext, guint row, guint column, guint min, guint max, - Glib::ustring const &pref_path) + Glib::ustring const &pref_path) { _actionList.push_back( new ActionE(id, tiptext,row, column,*this,min ,max, pref_path )); } @@ -351,7 +367,7 @@ void SprayOptionClass::addFButton(const Glib::ustring &id, const Glib::ustring &tiptext, guint row, guint column, Glib::ustring const &pref1_path, - Glib::ustring const &pref2_path) + Glib::ustring const &pref2_path) { _actionList.push_back( new ActionF(id, tiptext,row, column,*this,pref1_path, pref2_path )); } diff --git a/src/ui/dialog/spray-option.h b/src/ui/dialog/spray-option.h index 75dfe1e35..42090a120 100644 --- a/src/ui/dialog/spray-option.h +++ b/src/ui/dialog/spray-option.h @@ -33,11 +33,11 @@ #include "graphlayout/graphlayout.h" #include "inkscape.h" #include "macros.h" -#include "node-context.h" +#include "node-context.h" #include "preferences.h" #include "removeoverlap/removeoverlap.h" #include "selection.h" -#include "shape-editor.h" +#include "shape-editor.h" #include "sp-flowtext.h" #include "sp-item-transform.h" #include "sp-text.h" @@ -71,19 +71,19 @@ private: SprayOptionClass(SprayOptionClass const &d); SprayOptionClass& operator=(SprayOptionClass const &d); - + public: SprayOptionClass(); - virtual ~SprayOptionClass(); + virtual ~SprayOptionClass(); void test() { cout<<"appel de test !!"< _actionList; - Gtk::Frame _distributionFrame, _Frame, _FFrame ; - Gtk::Table _distributionTable, _gaussianTable, _ETable, _FTable; + Gtk::Frame _distributionFrame; + Gtk::Frame _Frame; + Gtk::Frame _FFrame; + Gtk::Table _distributionTable; + Gtk::Table _gaussianTable; + Gtk::Table _ETable; + Gtk::Table _FTable; Gtk::HBox _anchorBox; - Gtk::HBox _unifBox, _gaussianBox, _HBox, _FHBox, _BoutonBox; - Gtk::VBox _distributionBox, _VBox, _FVBox, _ActionBox; + Gtk::HBox _unifBox; + Gtk::HBox _gaussianBox; + Gtk::HBox _HBox; + Gtk::HBox _FHBox; + Gtk::HBox _BoutonBox; + Gtk::VBox _distributionBox; + Gtk::VBox _VBox; + Gtk::VBox _FVBox; + Gtk::VBox _ActionBox; Gtk::Label _anchorLabel; - Gtk::Label _unifLabel, _gaussLabel, _Label, _FLabel; - Gtk::CheckButton _unif, _gauss; + Gtk::Label _unifLabel; + Gtk::Label _gaussLabel; + Gtk::Label _Label; + Gtk::Label _FLabel; + Gtk::CheckButton _unif; + Gtk::CheckButton _gauss; Gtk::ComboBoxText _combo; Gtk::Tooltips _tooltips; - }; diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 5824b102c..743502d27 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -714,7 +714,7 @@ int sp_icon_get_phys_size(int size) static int lastSys[Inkscape::ICON_SIZE_DECORATION + 1]; static int vals[Inkscape::ICON_SIZE_DECORATION + 1]; - size = CLAMP( size, GTK_ICON_SIZE_MENU, Inkscape::ICON_SIZE_DECORATION ); + size = CLAMP( size, static_cast(GTK_ICON_SIZE_MENU), static_cast(Inkscape::ICON_SIZE_DECORATION) ); if ( !sizeMapDone ) { injectCustomSize(); diff --git a/src/widgets/ruler.cpp b/src/widgets/ruler.cpp index c90b55e73..c70d96991 100644 --- a/src/widgets/ruler.cpp +++ b/src/widgets/ruler.cpp @@ -727,6 +727,7 @@ sp_vruler_size_allocate (GtkWidget *widget, GtkAllocation *allocation) // code, those warnings are actually desired. They say "Hey! Fix this". We // definitely don't want to hide/ignore them. --JonCruz +// TODO address const/non-const gchar* issue: /// Ruler metrics. static GtkRulerMetric const sp_ruler_metrics[] = { // NOTE: the order of records in this struct must correspond to the SPMetric enum. diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index f5f1094f0..436213946 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -4408,11 +4408,13 @@ static void sp_spray_width_value_changed( GtkAdjustment *adj, GObject */*tbl*/ ) prefs->setDouble( "/tools/spray/width", adj->value ); } -static void sp_spray_force_value_changed( GtkAdjustment *adj, GObject */*tbl*/ ) +/* +static void sp_spray_force_value_changed( GtkAdjustment * / *adj* /, GObject * / *tbl* / ) { //Inkscape::Preferences *prefs = Inkscape::Preferences::get(); //prefs->setDouble( "/tools/spray/force", adj->value * 0.01 ); } +*/ static void sp_spray_mean_value_changed( GtkAdjustment *adj, GObject */*tbl*/ ) { @@ -4432,7 +4434,7 @@ static void sp_spray_pressure_state_changed( GtkToggleAction *act, gpointer /*da prefs->setBool("/tools/spray/usepressure", gtk_toggle_action_get_active(act)); } -static void sp_spray_mode_changed( EgeSelectOneAction *act, GObject *tbl ) +static void sp_spray_mode_changed( EgeSelectOneAction *act, GObject */*tbl*/ ) { int mode = ege_select_one_action_get_active( act ); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -6571,7 +6573,7 @@ sp_text_toolbox_family_keypress (GtkWidget */*w*/, GdkEventKey *event, GObject * } gboolean -sp_text_toolbox_family_list_keypress (GtkWidget *w, GdkEventKey *event, GObject */*tbl*/) +sp_text_toolbox_family_list_keypress (GtkWidget */*w*/, GdkEventKey *event, GObject */*tbl*/) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (!desktop) return FALSE; @@ -6759,14 +6761,14 @@ cell_data_func (GtkCellLayout */*cell_layout*/, g_free(family_escaped); } -gboolean text_toolbox_completion_match_selected (GtkEntryCompletion *widget, - GtkTreeModel *model, - GtkTreeIter *iter, - GObject *tbl) +gboolean text_toolbox_completion_match_selected(GtkEntryCompletion */*widget*/, + GtkTreeModel *model, + GtkTreeIter *iter, + GObject *tbl) { // We intercept this signal so as to fire family_changed at once (without it, you'd have to // press Enter again after choosing a completion) - gchar *family; + gchar *family = 0; gtk_tree_model_get(model, iter, 0, &family, -1); GtkEntry *entry = GTK_ENTRY (g_object_get_data (G_OBJECT (tbl), "family-entry")); @@ -6799,9 +6801,9 @@ cbe_add_completion (GtkComboBoxEntry *cbe, GObject *tbl){ g_object_unref(completion); } -void sp_text_toolbox_family_popnotify (GtkComboBox *widget, - void *property, - GObject *tbl) +void sp_text_toolbox_family_popnotify(GtkComboBox *widget, + void */*property*/, + GObject *tbl) { // while the drop-down is open, we disable font family changing, reenabling it only when it closes @@ -7109,7 +7111,7 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl { return; } - + // quit if run by the _changed callbacks if (g_object_get_data( tbl, "freeze" )) { @@ -7160,7 +7162,7 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl) { return; } - + // quit if run by the _changed callbacks if (g_object_get_data( tbl, "freeze" )) { @@ -7280,7 +7282,7 @@ static void sp_nooverlaps_graph_layout_toggled( GtkToggleAction* act, GtkObject } -static void connector_length_changed(GtkAdjustment *adj, GObject* tbl) +static void connector_length_changed(GtkAdjustment *adj, GObject* /*tbl*/) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble("/tools/connector/length", adj->value); @@ -7495,9 +7497,9 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_connector_new_connection_point), holder ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); } - + // Remove selected connection point button - + { InkAction* inky = ink_action_new( "ConnectorRemoveConnPointAction", _("Remove connection point"), @@ -7507,7 +7509,7 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_connector_remove_connection_point), holder ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); } - + // Code to watch for changes to the connector-spacing attribute in // the XML.